Commit e322ef8
authored
chore(profiling): dont call clear in postfork_child (#19121)
[PROF-15438](https://datadoghq.atlassian.net/jira/software/c/projects/PROF/boards/11?selectedIssue=PROF-15438)
workspace-gyuheon-1
## Description
Instead of calling `reset()` (which calls `thread_id_to_span.clear()` and would traverse potentially corrupted pointers inherited from a fork that raced with a mutation), it reconstructs the map in place using `placement-new`. This intentionally leaks the old map's nodes, but this is safe/necessary since inspecting or destroying the inconsistent container would be UB.
`clear()` is still used in [stack.cpp](https://github.com/DataDog/dd-trace-py/blob/b25d7df821cfdcf76d49db604a1f36beb2c1d515/ddtrace/internal/datadog/profiling/stack/src/stack.cpp#L44-L55) so we keep it
This follows th[e pattern of what we do for](https://github.com/DataDog/dd-trace-py/blob/4e5894b231c777cf4b47c4c49e8a9ab7a9f07868/ddtrace/internal/datadog/profiling/stack/echion/echion/strings.h#L89-L104) `StringTable`:
## Testing
<!-- Describe your testing strategy or note what tests are included -->
## Risks
<!-- Note any risks associated with this change, or "None" if no risks -->
## Additional Notes
<!-- Any other information that would be helpful for reviewers -->
[PROF-15438]: https://datadoghq.atlassian.net/browse/PROF-15438?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Co-authored-by: gyuheon.oh <gyuheon.oh@datadoghq.com>1 parent 831271e commit e322ef8
1 file changed
Lines changed: 12 additions & 2 deletions
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | | - | |
57 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
58 | 68 | | |
59 | 69 | | |
60 | 70 | | |
0 commit comments