DescriptionWorkaround attempt for timeout flakiness: Avoid running atexit() handlers in fork()ed process on linux
About this CL:
The only purpose of `if (fork() == 0) exit(0)` is to wake up
a thread in the parent process which might be blocked on `wait()`.
There is no need to run atexit() handlers in the `fork()`ed child.
This is a *workaround attempt* for a deadlocked `free()` call inside the
processing of atexit handlers in glibc.
(Side note: There might be better ways of notifying the thread, like sending a
signal to the particular pthread with `pthread_kill` which would make the
`wait()` syscall be interrupted.)
About the issue:
It is still unclear why, in this particular case, the tcmalloc locks should
be hold during the `exit()` call:
* via a static initializer tcmalloc uses
`pthread_atfork(before=ObtainAllLocks(),
after_parent=ReleaseAllLocks(),
after_child=ReleaseAllLocks())`
to register locking & unlocking around `fork()`
* glibc's `fork()` runs the either `after_parent` or `after_child` handlers
(unconditionally) which should free the locks
* the `exit()` call later should be free to malloc/free
The [BUG] describes more in detail how we can hit a tcmalloc deadlock in a
different situation (it's a linux kernel bug).
Namely, if the linux kernel runs OOM during `fork()` and therefore fails to
set the new thread-id. The glibc code hits an assert and tries to allocate
memory before `after_parent`/`after_child` handlers were executed which
deadlocks.
BUG=https://github.com/dart-lang/sdk/issues/28246
R=vegorov@google.com
Committed: https://github.com/dart-lang/sdk/commit/e0a427a9572c41804b7f45008a6725fe376b17f9
Patch Set 1 #
Total comments: 4
Patch Set 2 : add comment #
Messages
Total messages: 6 (2 generated)
|