[fpc-devel] Improper OUT usage.

Vincent Snijders vincent.snijders at gmail.com
Sun Mar 10 15:43:14 CET 2013


2013/3/9 Marco van de Voort <marcov at stack.nl>:
>
> 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.
>

You found a big in fcp-passrc, because if you have an out parameter,
then the callee has to output a valid variable. If it asumes that is
initialized when called, then it must use var instead.

Vincent



More information about the fpc-devel mailing list