Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: ForkSanitizer #47

Closed
ramosian-glider opened this issue Aug 31, 2015 · 6 comments
Closed

RFC: ForkSanitizer #47

ramosian-glider opened this issue Aug 31, 2015 · 6 comments

Comments

@ramosian-glider
Copy link
Member

Originally reported on Google Code with ID 47

When the process call fork(), its address space is copied, including the instances of
AsanThread.

This is generally not a good idea, because any existing pthreads die at fork, and accessing
their memory becomes incorrect.

I think we should intercept fork(), destroy the non-existing AsanThread instances and
do something with their shadow.

Reported by ramosian.glider on 2012-03-15 12:23:46

@ramosian-glider
Copy link
Member Author

Reported by ramosian.glider on 2012-03-15 12:24:05

  • Labels added: Type-Enhancement, Priority-Low
  • Labels removed: Type-Defect, Priority-Medium

@ramosian-glider
Copy link
Member Author

Do you have a *sane* motivating example? 
Generally, mixing fork and threads is considered harmful even w/o asan. 
We are not making things worse. 

Reported by konstantin.s.serebryany on 2012-03-15 17:41:20

  • Status changed: WontFix

@ramosian-glider
Copy link
Member Author

Motivation is exactly what you say - it's generally harmful to call fork() if you have
multiple threads, especially if you rely on contents of thread-local memory (say, use
variables stored in stacks of other threads). We can potentially produce error report
in such cases.

Reported by samsonov@google.com on 2012-03-16 05:57:00

@ramosian-glider
Copy link
Member Author

Alexey has yesterday found a nice example of a custom condvar implementation that pings
the threads waiting on it by updating their local variables.
Someone creates two threads waiting on the same condvar and calls fork(). In the child
process the second thread disappears. Once the first thread releases the condvar, it
writes some value in the place where the second thread's stack used to be.

(In this particular case the third thread had already started and reused the stack
of the second thread, which was quite a problem)

Reported by ramosian.glider on 2012-03-16 17:08:08

@ramosian-glider
Copy link
Member Author

Um-m, afair there were no writes, reads were enough to spoil things:
threads waiting on a condvar create structs on their local stacks, and ptrs
to these structs are stored in a queue associated with condvar. If a thread
disappears after a fork(), its local stack gets re-used in a child process,
and we'll read garbage while accessing condvar from a child process.

Reported by samsonov@google.com on 2012-03-19 09:07:42

@ramosian-glider
Copy link
Member Author

Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:12:58

  • Labels added: ProjectAddressSanitizer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant