possible race condition with forked process
Stephen Bartnikowski <sbartnikowski <at> barkinglizards.com>
2006-11-15 20:17:46 GMT
I'm essentially calling LOG4CXX_INFO in a child process between a call to
fork() and a call to execv() on FreeBSD 6.0. The child process blocks
indefinitely maybe 1 in 4 times upon calling the LOG4CXX_INFO macro. If it
doesn't block there, log4cxx calls after the execv work fine. If I remove
the call between the fork and execv, then I never encounter the problem.
I was using 0.9.7, so I was hoping the latest from SVN would fix my issue.
However, upgrading did not improve the situation. I am interested to try
this on my Linux machine, but it will take some time to get the latest
log4cxx installed on there as well.
Would there be any race conditions involved in calling LOG4CXX_INFO using
the parent's logger object between a fork and exec? I know the parent's
memory is supposed to be copied for the child after the fork, rather than
shared, but I can imagine something could get broken in the copy-on-write,
or maybe mutex initialization, or even static data.