Search code examples
regexlinuxgccthread-safetylibc

Are regex functions like "regexec" thread safe in libc version 2.2.5?


I've read that regex functions in the libc should be threadsafe, but I've also read that in earlier version it was not the case.

I now have to work on an embedded system that has an old libc version 2.2.5 .

So I'm not really sure if functions like "regexec" are thread safe or if they should be protected by a mutex?

If anyone has any clue about this, I would be grateful. I'm also not very sure about what I should test against to verify the thread safety of these functions.


Solution

  • I searched the NEWS file in a recent libc version (2.13) for the regex keyword. There is nothing about thread safety, but the following note :

    Version 2.3    
    ...
    
    Isamu Hasegawa contributed a completely new and POSIX-conformant implementation
    of regex.
    

    But according to this, there have been some concurrency issue after 2.3 so things does not look so good for 2.2.5

    According to this very similar question POSIX conformance means regexec must be thread safe, but it does not mean there is no concurrency bug in earlier version of the libc.