bloomberg / memray

Memray is a memory profiler for Python
https://bloomberg.github.io/memray/
Apache License 2.0
13.17k stars 392 forks source link

Set our recursion guard in all hooks #433

Closed godlygeek closed 1 year ago

godlygeek commented 1 year ago

This prevents reentrancy if one hooked function calls into another. For instance, the jemalloc implementation of malloc calls into mmap while holding a lock, and our mmap hook calls malloc, so we must prevent our mmap hook from running beneath our malloc hook.

Closes #336

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% :warning:

Comparison is base (a519a95) 91.72% compared to head (88c5853) 91.72%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #433 +/- ## ========================================== - Coverage 91.72% 91.72% -0.01% ========================================== Files 90 90 Lines 10503 10520 +17 Branches 1446 1446 ========================================== + Hits 9634 9649 +15 - Misses 866 868 +2 Partials 3 3 ``` | Flag | Coverage Δ | | |---|---|---| | cpp | `85.19% <100.00%> (+0.01%)` | :arrow_up: | | python_and_cython | `95.18% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files Changed](https://app.codecov.io/gh/bloomberg/memray/pull/433?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg) | Coverage Δ | | |---|---|---| | [src/memray/\_memray/hooks.cpp](https://app.codecov.io/gh/bloomberg/memray/pull/433?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg#diff-c3JjL21lbXJheS9fbWVtcmF5L2hvb2tzLmNwcA==) | `98.20% <100.00%> (+0.20%)` | :arrow_up: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/bloomberg/memray/pull/433/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.