Comment #4 on issue 255 by [email protected]: Forking threads fails with clang 3.4
http://code.google.com/p/address-sanitizer/issues/detail?id=255

I've attached a patch that fix my issue (only on Linux, in a quick and dirty fashion). The idea is to have a registry of AsanThreads. When a thread is created or destroyed, the registry is updated. After forking, in the child process, we scan the registry in order to destroy all the threads that didn't survive the fork. The patch depends on pthread_atfork() to perform the cleanup. The registry implementation is naïve and limited. And only linux is implemented and tested. Also I didn't include a test.

I still perfectly agree that mixing fork and threads in the general case is dangerous. However, I also still believe that my use case is perfectly valid: I use fork() as a way to take a snapshot of the memory of my database in order to be able to make a snapshot while still accepting updates in the parent process (I don't think there is a better solution for this). The threads are not strictly required in the child process, however they are mandatory in the parent process. In my use case the child process only writes data that is in memory onto the disk, since it works on a snapshot of the memory it does not need synchronization (so all the argument about critical sections don't apply).

Hope this can help.

Attachments:
        0001-asan-clear-threads-when-forking.patch  3.4 KB

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to