[Patch, Fortran] PR42517: Bogus runtime error with -fopenmp -fcheck=recursion

Janus Weil janus@gcc.gnu.org
Tue Dec 29 21:30:00 GMT 2009


>> I recently noticed that -fcheck=recursion does not work together with
>> OpenMP. This is not surprising, since all that the recursion check
>> does is setting some internal logical variable to true when entering
>> the procedure and setting it back to false when leaving. So that, if
>> the procedure is already being executed, a second instance of that
>> procedure can detect this situation and throw a runtime error.
>>
>> Now, in an OpenMP program you typically have several parallel threads,
>> and any procedure can simultaneously be executed in multiple threads
>> without being called recursively. Therefore the recursion check simply
>> does not work for this case and throws false errors galore.
>
>> Surely there are ways to make the check work also for parallel
>> programs.
>
>  Yes, that's what TLS was made for; I hesitate to use the word "trivial"
> since it won't be, but conceptually it is: just create a __thread variable
> instead of an ordinary static one for the recursion check guard var.

Thanks for the hint. I have no experience with TLS, so I wouldn't know
how to do that right away. The biggest hurdle would probably be the
fact that TLS is not supported in the Fortran front end. Or is it? I
mean, is it possible to declare a TLS variable in a Fortran program?

Btw, since I just had a look at it: There seem to be some funny
artifacts in the chapters on TLS in the manual, stuff like "Add new
text after paragraph ..." etc (chapter 6.56.1 and 6.56.2).

Cheers,
Janus



More information about the Gcc-patches mailing list