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

Wrappers for custom allocators #10

Closed
fcoiffie opened this issue Feb 12, 2019 · 4 comments
Closed

Wrappers for custom allocators #10

fcoiffie opened this issue Feb 12, 2019 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@fcoiffie
Copy link

Is it possible to catch and to track calls to custom allocators (malloc()/free() like functions) (for detecting memory leaks) ?

In my specific case, I'm using DPDK which provides its own memory management functions (https://doc.dpdk.org/api/rte__malloc_8h.html). For this kind of heavy load application, Valgrind is unusable. MALT seems to work with my application for usual malloc()/free() but I would like to extend its use to the custom allocator.

@svalat
Copy link
Member

svalat commented Feb 18, 2019

Hi, yes we can make it without too much work, this is a really interesting use case.

I had the question at FOSDEM in the audience (maybe that's you ;)).

Will do somthing.

So I would think you have somehting like my_malloc()/my_free() inside your projet and I can find a way to intercept and redirect onto my malloc tracking.

I just need a clean way to pass as parameter to build a libray in flight or give hints to do your own by hand. That would match your expectation ?

Also, your internal alloc is inside a .so file ? Or built-in directly your executable ? For second case you will need to at least link a dedicated .so file pointing malt or just providing override capability on your funcitons.

@svalat svalat added enhancement New feature or request good first issue Good for newcomers labels Feb 18, 2019
@svalat svalat added this to the v1.0.1 milestone Feb 18, 2019
@fcoiffie
Copy link
Author

Hi,

I didn't attend FOSDEM but glad to know that someone else has the same needs.

As we link the allocation library statically with our executable, I think will have to modify the implementation itself (or use a little wrapper) but it's not a real problem.

@svalat
Copy link
Member

svalat commented Feb 21, 2019

Ok, thanks for details. So I will first provide functions you can call by linking a fake lib to your code or something similar. That might be fine for a first try then I will look on more automatic interception of allocators in .so files.

@svalat svalat modified the milestones: v1.1.0, v1.2.0 Apr 12, 2019
svalat added a commit that referenced this issue Dec 7, 2022
@svalat
Copy link
Member

svalat commented Dec 7, 2022

This is now done by providing some options on the malt command :

malt --wrap malloc:je_malloc,free:je_free ./prgm

Or more generic to wrap all the memoy managment function under a given prefix:

malt --wrap-prefix je_ ./prgm

You can wrap several prefix or set of function.

The only limitation is that you will not distinguish them from standard malloc in the final profile.

svalat added a commit that referenced this issue Dec 8, 2022
@svalat svalat closed this as completed Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants