(1) Most probable -- not a bug in CPG, but an uninitialized variable in computeResiduals (or any routines it calls). The writeln statement causes the stack or some register look different. So, first to do, is to check all your local variables.
(2) Less probable -- writeln doesn't preserve registers the right way.
Adriaan van Os