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
test_multiprocessing_spawn segfaults on AMD64 FreeBSD CURRENT Shared 3.x #81316
Comments
test_import (test.test_multiprocessing_spawn._TestImportStar) ... ok https://buildbot.python.org/all/#/builders/168/builds/1124/steps/5/logs/stdio |
Maybe it's related to bpo-33608. |
Would be nice if someone could post a gdb backtrace of the core dump. |
I am unable to reproduce this locally, will post here a backtrace if I manage to do so. |
https://bugs.python.org/issue33608#msg340075:
I ran this test for 20 min on the FreeBSD CURRENT buildbot: I failed to reproduce the bug. |
Adding the release manager to consider this |
FTR Victor reverted #57923 that triggers this. |
Given the nature of the bugs, I would recommend to watch the buildbots |
Sadly, this revert wasn't enough. New fresh coredump on "AMD64 FreeBSD CURRENT Shared 3.x": Warning -- Dangling processes: {<SpawnProcess |
CURRENT-amd64% lldb ./python -c python.core
|
I looked at the coredump with Pablo. In short, the main thread is calling Py_Exit() to exit the process and so released memory, and a daemon thread does crash on calling PyEval_RestoreThread() because tstate memory was freed. The question is now if this bug is a regression compared to Python 3.7 or not. I'm trying to reproduce it on Linux by adding "sleep(1)" before exit, but my attempts are unsuccessful so far. |
Note that the core dump that we are talking about is something that we produced afterwards when trying to reproduce the issue. The core that is produced as part of the tests could be different. I am trying to get access to the test files. |
If you apply attached sleep_at_exit.patch and run attach stress.py, you should quickly get a crash: $ git apply sleep_at_exit.patch
$ make && ./python stress.py
Segmentation fault (core dumped) That's a simplified example of the multiprocessing crash. |
I used git bisect and I found: commit 396e0a8 (refs/bisect/bad)
stress.py starts to crash at this change. |
Extract of this change:
static inline void
-exit_thread_if_finalizing(_PyRuntimeState *runtime, PyThreadState *tstate)
+exit_thread_if_finalizing(PyThreadState *tstate)
{
+ _PyRuntimeState *runtime = tstate->interp->runtime;
/* _Py_Finalizing is protected by the GIL */
if (runtime->finalizing != NULL && !_Py_CURRENTLY_FINALIZING(runtime, tstate)) {
drop_gil(&runtime->ceval, tstate);
@@ -236,7 +237,7 @@ PyEval_AcquireLock(void)
Py_FatalError("PyEval_AcquireLock: current thread state is NULL");
}
take_gil(ceval, tstate);
- exit_thread_if_finalizing(runtime, tstate);
+ exit_thread_if_finalizing(tstate);
}
This change is fine for regular Python threads. But for daemon threads, tstate is likely already corrupted, so it's no longer possible to get interp from interp, and so also not possible to get 'runtime'. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: