Alex Rivera | Logout

Is there a way to flag the use of non-reentrant C library calls?

Asked 2011-06-24T01:25:47.573
12

I'm working on a project that's heavily multi-threaded, and was wondering if there's a way to have the compiler flag the use of non-reentrant calls to the C library (e.g. strtok intsead of strtok_r)? If not, is there a list of calls that are non-reentrant so I can grep through my code base periodically?

A related question is if there's a way to flag 3d party library use of non-reentrant calls.

I'm assuming reentrancy implies thread-safety, but not necessarily the other way around. Is there a good reason to use non-reentrant calls in a threaded project?

Edit
Report

1 Answer

0

For binaries, you can use LD_PRELOAD to intercept whatever C library functions you like and take whatever action you want (abort, log an error but proceed, etc.)

During development, you can also use valgrind to do the same.

For some sample code and references, see the answers to how could I intercept linux sys calls?

answered 2011-06-24T04:34:08.063

Your Answer