GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing github.com — Detect if calloc calls malloc by apangin · Pull Request #1500 · async-profiler/async-profiler Conversation
Collaborator
DescriptionUse temporary malloc hook to detect if Related issuesMotivation and contextVarious malloc implementations may or may not do cross-calls. For example, default How has this been tested?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
While thinking about this issue, the solution that made most sense to me was something along the lines of what is implented here However I have some doubts On a similar note, do we want to support other patterns the user might introduce via an LD_PRELOAD? (For example a user might change malloc to call calloc) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Baraa-Hasheesh Checking only one type of relation (calloc calling malloc) was a conscious choice. This relation is a distinctive characteristic of musl's own memory allocator. Other popular allocators (glibc's malloc, jemalloc, tcmalloc, mimalloc) do not do cross-calls via PLT. Checking relation between posix_memalign and aligned_alloc would require writing more code in vain (with no effect for the above allocators). At the same time, it would not be a complete solution for a custom user-provided allocator anyway. Support for custom allocators that hook arbitrary |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| static bool _recursive_malloc = false; | ||
|
|
||
| // Test if calloc() implementation calls malloc() | ||
| static void* recursive_malloc_hook(size_t size) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Not sure if "recursive" is the right naming, as function is not calling itself.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I had doubts about that too, but decided it's still recursive in the sense the malloc algorithm (as the whole) calls to itself via PLT. Do you have a suggestion how to name it better?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Renamed to nested
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"Nested" sounds good, as we are calling all malloc-family functions malloc here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Fixes `nativemem` profiling on Alpaquita Linux
Fixes `nativemem` profiling on Alpaquita Linux
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.