Record successful attach only after attaching in SuspendAttach - #6404
Conversation
Merging this PR will degrade performance by 12.79%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | into_u128_small |
876.1 ns | 1,041.4 ns | -15.87% |
| ❌ | into_u128_zero |
816 ns | 925.7 ns | -11.85% |
| ❌ | extract_bigint_small |
1.4 µs | 1.6 µs | -10.55% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing ngoldbaum:fix-shutdown-race (63cb82b) with main (fc4d08c)
Footnotes
-
6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
| } | ||
|
|
||
| /// Wrapper to mark Receiver as Sync. | ||
| struct SyncReceiver<T>(std::sync::mpsc::Receiver<T>); |
There was a problem hiding this comment.
not needed since Rust 1.73
|
ping for a review here @davidhewitt |
davidhewitt
left a comment
There was a problem hiding this comment.
Yikes, just when I thought we'd finally closed all these finalization bugs!
I think given we're hopefully about to ship 0.30 I'm not rushing to back port this, WDYT?
|
Yeah that's fine from my end. |
SuspendAttach::dropincrementsATTACH_COUNTbefore successfully attaching. This was missed during review of #6085 (ping @anuraaga). The fix is to only increment if we actually successfully attach.This bug can lead to crashes if the attach happens during interpreter shutdown on pythons older than 3.13.8.
I hit this while working on Quansight/spinningjenny#14. See the workaround there for how I'm avoiding the problem.
spinningjennystores state in Rust TLS, and that pattern does not look like any existing tests in PyO3.I updated the testing utilities we use in
test_finalization.pyto trigger this. It unfortunately requires a decent amount of complexity to ensure the race is triggered deterministically.Adding the soundness label because I think the current behavior is unsound.