Open lefessan opened 9 months ago
I stumbled on that one in #116 . Copy-pasting my analysis.
The failure is random, sometimes the test is OK, sometimes it fails. The problem occurs specifically with STOP RUN (replacing by an EXIT program gives no error). Also, it does NOT occur if we define COB_WITHOUT_JMP. Investigating a bit, it seems this is because the COBOL module executing the STOP RUN statement is unloaded (with lt_dlclose) before cob_stop_run has finished its execution. This might be okay when calling exit, but when using longjmp, this probably messes up the stack frame.
Instead of compiling with COB_WITHOUT_JMP
it likely would also work to just disable the dlclose()
by using COB_PHYSICAL_CANCEL=never $COBCRUN_DIRECT ./caller callee2
(inline, only for that run), right?
What may works is COB_PRE_LOAD=callee2 $COBCRUN_DIRECT ./caller callee2
If this works we could do that in the testsuite and document that this may be necessary on some environments (known: Windows) or change the function cob_call_with_exception_check()
(but then likely cob_call()
, too) to set a flag "called by API" and always skip the complete module unloading part.
@ddeclerck Could you have a look at this, please?
@ddeclerck Could you have a look at this, please?
Sure (as soon as I find a moment).
Finally had time to have a look at this one.
So, using COB_PHYSICAL_CANCEL=never
does indeed prevent the bug from occurring.
However COB_PRE_LOAD=callee2
does not help.
Now, what should we do ? Just add the workaround in the testsuite and document cob_call_with_exception_check
as unsuitable for Windows ? Or as you suggest implement a flag to prevent unloading when calling from cob_call_with_exception_check
?
I'd prefer the second - and document that modules will only be unloaded with this function if after the call a manual call to cob_tidy()
is done.
From https://github.com/OCamlPro/gnucobol/actions/runs/6675975179?pr=109