-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
nogil segmentation fault on ordered dict operations #125996
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
Comments
This comment has been minimized.
This comment has been minimized.
gdb uses ptrace to attach to the process, our experience is that ptrace changes timings and thread schedulings. Can you confirm it crashes outside of gdb? We'll try to get a stacktrace and more info on this, we'll also try your version. |
This comment has been minimized.
This comment has been minimized.
I can reproduce this if I run the script provided by @luisggpina in a loop. Here is a sample stacktrace: https://gist.github.com/mpage/60b274f14c26cca1429fdfe98cc74ef9. Built with
I don't think anyone has looked at making ordereddict thread-safe yet, so I'm not surprised to see a crash here. |
Lines 1300 to 1322 in c5b99f5
I successfully triggered the error, and it turns out that the underlying operation of move_to_end is not atomic. If this is not considered from the beginning of the design, and the author does not intend to take over this task, I request to fix the issue. Edit:
It will be consistent with the append operation of the list.
|
Thanks for the proposed fix! Here's a case that might be problematic:
To increase the odds of finding this behavior, you can add calls to Apologies if I misunderstood your proposed fix, but I'm curious about the case where the dict changes in a meaningful way (e.g., non empty to empty) while the method is active. |
Thanks for the bug report.
It's slightly more embarrassing than that. Dino started to look at OrderedDict back in January, and I suggested we defer it at the time and then forgot to revisit it. Given that 3.13.0 is already released, my preference would be:
|
Crash report
What happened?
Hi,
We're a research group focused on testing concurrent runtimes. Our work-in-progress prototype found a segmentation fault on the current nogil build when using concurrent operations on the same ordered dict. The program below shows the crash.
We ran this on our build from source configured with
./configure --disable-gil
.Here's some details about the OS, compiler, binutils:
Linux version 5.15.0-124-generic (buildd@lcy02-amd64-118) (gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #134-Ubuntu SMP Fri Sep 27 20:20:17 UTC 2024
@flypoodles and @overlorde are part of the team, adding them so they get notified about further discussion.
We're happy to provide more details about the crash.
CPython versions tested on:
3.13, 3.14, CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a1+ experimental free-threading build (heads/main:c5b99f5c2c5, Oct 25 2024, 17:31:30) [GCC 11.4.0]
The text was updated successfully, but these errors were encountered: