Skip to content

Conversation

claeusdev
Copy link

closes #725

This commit introduces 2 new functions to add support for free_sized and free_aligned_sized deallocators introduced in c23.

Tests ensure that free_sized and free_aligned_sized are skipped if unavailable otherwise we get a FREE record recorded for them.

Copy link
Contributor

@godlygeek godlygeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good start, but I see a lot of things here that don't look right.

@claeusdev claeusdev requested a review from godlygeek August 29, 2025 16:07
@claeusdev claeusdev force-pushed the support_new_deallocators branch from 653f4e6 to 79ca2a2 Compare August 29, 2025 18:05
@codecov-commenter
Copy link

codecov-commenter commented Aug 29, 2025

Codecov Report

❌ Patch coverage is 20.40816% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.76%. Comparing base (1425302) to head (88f0b37).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
tests/integration/test_extensions.py 23.25% 33 Missing ⚠️
src/memray/_memray/hooks.cpp 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #817      +/-   ##
==========================================
- Coverage   92.19%   90.76%   -1.44%     
==========================================
  Files          95       95              
  Lines       11940    11985      +45     
  Branches      413      415       +2     
==========================================
- Hits        11008    10878     -130     
- Misses        932     1107     +175     
Flag Coverage Δ
cpp 90.76% <20.40%> (-1.44%) ⬇️
python_and_cython 90.76% <20.40%> (-1.44%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@claeusdev claeusdev force-pushed the support_new_deallocators branch from 79ca2a2 to 88f0b37 Compare September 8, 2025 13:27
@godlygeek
Copy link
Contributor

Don't worry about the failing macOS test, that will be fixed by a rebase after we land #752

It looks like we're ahead of the curve here. Neither glibc nor musl libc suppport free_sized and free_aligned_sized yet (patches have been submitted to both for adding support, but not yet merged for either). Given that, I'm not sure how we can really test that this is working.

Hm. @pablogsal do you think it would be reasonable to have our tests build in C99 mode, instead of C23, and LD_PRELOAD a shared library of our own creation that provides free_sized and free_aligned_sized? Or do you think that's too different from the real case where they're provided by libc to be a trustworthy test proving that our interposition is working?

@pablogsal
Copy link
Member

Hm. @pablogsal do you think it would be reasonable to have our tests build in C99 mode, instead of C23, and LD_PRELOAD a shared library of our own creation that provides free_sized and free_aligned_sized? Or do you think that's too different from the real case where they're provided by libc to be a trustworthy test proving that our interposition is working?

I don't think this will be very useful. We already know our interposition works but what we want to check is that indeed works with GLIBC as most of the trickery can happen when we deal with the real implementation: we can be dealing with weak symbols, versioned symbols, weird redirects ...etc Having our own fake shared object would not help a lot with that

This commit introduces 2 new functions to add support for
`free_sized` and `free_aligned_sized` deallocators introduced in
c23.

We ensure that `free_sized` and `free_aligned_sized` are skipped if
unavailable otherwise we get a `FREE` record recorded for them.

Signed-off-by: Nana Adjei Manu <[email protected]>
Remove `glibc` guards for new functions to support all libc
implementations.

Updates tests to skip if compilation fails on a specific platform.

Signed-off-by: Nana Adjei Manu <[email protected]>
Update line number assertions in three failing integration tests to match
current file structure after recent code additions. The tests were failing
due to line number shifts caused by:

- Addition of C23 deallocator support tests
- Code review improvements

Tests affected:
- test_misbehaving_extension: 83 → 85
- test_extension_that_uses_pygilstate_ensure: 154 → 156, 155 → 157
- test_native_dlopen: 226 → 228

Signed-off-by: Nana Adjei Manu <[email protected]>
@claeusdev claeusdev force-pushed the support_new_deallocators branch from 88f0b37 to 0156107 Compare October 1, 2025 18:02
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.

Intercept new free_sized and free_aligned_sized functions
4 participants