Fix thread-safety violation in Allocations Profiler: Use a per-thread bt_data buffer#44114
Fix thread-safety violation in Allocations Profiler: Use a per-thread bt_data buffer#44114
Conversation
9a62751 to
d7f3674
Compare
|
Could some allocations happen while an exception is being thrown and this buffer is holding the exception backtrace? 🤔🤔 |
d7f3674 to
04e6c5a
Compare
|
yeah, that's a fantastic question @vilterp... I think @vtjnash is saying no that can't happen, because we basically immediately copy it off the buffer onto a properly sized object, once we know the size (same as we were doing), such as here: Lines 621 to 623 in 7ccc83e But I frankly can't tell. The comments indicating that we're supposedly using this buffer for rooting implies to me that YES this can ABSOLUTELY happen, in which case 🙅 🙅 no good. But i would like to get some confirmation from others on this. Just in case, i've started a second PR with the other, simpler approach, of just creating a separate buffer for this, here: #44116 |
Re-use the shared `ptls->bt_data` buffer from the thread-local storage for the buffer, to ensure that each thread has a separate buffer. This buffer is shared with the exception throwing mechanism, but is safe to share since julia exception throwing never interleaves with allocations profiling.
04e6c5a to
e3fa8eb
Compare
|
Yes, we use |
|
To perhaps clear up some confusion here... the preallocated But we can't store backtraces permanently in |
|
Fixed by #44116 |
Re-use the shared
ptls->bt_databuffer from the thread-local storagefor the buffer, to ensure that each thread has a separate buffer.
This buffer is shared with the exception throwing mechanism, but is safe
to share since julia exception throwing never interleaves with
allocations profiling.
This fixes #44099.