memray icon indicating copy to clipboard operation
memray copied to clipboard

Intercept new `free_sized` and `free_aligned_sized` functions

Open godlygeek opened this issue 9 months ago • 3 comments

C23 adds two new deallocators, free_sized and free_aligned_sized, which we currently do not intercept. It's valid for an implementation to treat them exactly as it would treat calls to free.

godlygeek avatar Mar 23 '25 23:03 godlygeek

Hey @godlygeek I'm interested in picking this up. Do you have any pointers.

naamanu avatar Aug 20 '25 14:08 naamanu

I think that the best approach here is to add two new memray::intercept::free_sized and memray::intercept::free_aligned_sized functions in hooks.cpp, declare them and add them to MEMRAY_HOOKED_FUNCTIONS in hooks.h, and have the implementation in hooks.cpp just call memray::intercept::free. I think that might be all that's required to support these new deallocators.

Then, we'll need to add a new test that exercises these things. That test would need to be skipped if free_sized and free_aligned_sized aren't available, but otherwise that the test will call them from a test extension module and ensure that we get a FREE record recorded for them.

godlygeek avatar Aug 20 '25 15:08 godlygeek

Alright. it's clearer now.

naamanu avatar Aug 20 '25 17:08 naamanu