Skip to content
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

fix SharedPtr block destruction #15

Merged
merged 1 commit into from
May 11, 2024
Merged

fix SharedPtr block destruction #15

merged 1 commit into from
May 11, 2024

Conversation

jxy-s
Copy link
Collaborator

@jxy-s jxy-s commented May 11, 2024

SharedPtr was not correctly handling destruction of the block. The allocator would be destructed alongside the compressed pair when the strong reference went to zero. Then it would attempt to free using the allocator it just destructed. This is a problem for stateful allocators as it may have internal state that is rendered invalid after destruction.

The fix is to only destruct the managed object when the strong reference goes to zero. Then, when the weak reference goes to zero, take a copy of the allocator and destruct the remaining parts (including the internal allocator). Then use the copied allocator to carry out the free.

Copy link

codecov bot commented May 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.05%. Comparing base (6a49edb) to head (834c7d3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #15      +/-   ##
==========================================
- Coverage   91.08%   91.05%   -0.04%     
==========================================
  Files          17       17              
  Lines        1930     1934       +4     
  Branches      235      236       +1     
==========================================
+ Hits         1758     1761       +3     
  Misses         14       14              
- Partials      158      159       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jxy-s jxy-s merged commit 44f0e81 into main May 11, 2024
10 checks passed
@jxy-s jxy-s deleted the shared-ptr-fix branch May 11, 2024 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant