[fpc-devel] Improper OUT usage.

Marco van de Voort marcov at stack.nl
Sat Mar 9 21:35:38 CET 2013


I was debugging a problem in the generation of FCL documentation (CHM
format) with fpdoc (trunk), and found an interesting behaviour worth of
sharing;

The location of the exception didn't seem to give much info, so I hoped to
force problems to lead to early fails by recompiling with -CRriot and -gttt,
but this (I assume the -gttt) lead to the following:

the first problem is that fcl-passrc likes to use OUT for all kinds of
parameters, probably to silence some warnings.

BUT at the same time doesn't assign a value to it in all codepaths (in this
case the visibility checking methods).  At the same time, it passes global
or fields with state variables(enums, curvisibility in this case) to the OUT
parameters.

The result is that -gttt randomizes the OUT parameters on entry, the
parameters are never changed in some codepaths, and in those cases the global
state variable becomes corrupt, leading to all kinds of interesting
behaviour. (like undocumented InOutError 107, which I assume is a relatively
new RTE for printing out of range enums)

I changed the out parameters to VAR and the problem disappeared.

So be careful if you use OUT with types that have range limitations. Not
setting the out parameter can make debug tools like gttt difficult.



More information about the fpc-devel mailing list