Page MenuHomePhabricator

meson: defines EINA_DEBUG_MALLOC only if malloc_usable_size is used
Closed, ResolvedPublic


in, we have :

malloc_usable_size \


[test "x${ac_cv_func_malloc_usable_size}" = "xyes" && test "x${want_debug_malloc}" = "xyes"],
[1], [Turn on debugging overhead in mempool])

but in, EINA_DEBUG_MALLOC is defined only if the build type is debug.

that could be annoying (in eo_ptr_indirection.x and eina_chained_mempool.c)

we should update this check (i think easily possible as malloc_usable_size is checke in header_check/

vtorri created this task.Jun 23 2019, 7:40 AM
vtorri triaged this task as High priority.
zmike added a comment.Jun 24 2019, 6:05 AM

I think maybe I am not understanding this: what exactly are you proposing?

in src/lib/eina/, instead of

if debug_malloc

config_h.set('EINA_DEBUG_MALLOC', 1)


something like (i don't know the correct syntax) :

if debug_malloc && malloc_usable_size.have()

config_h.set('EINA_DEBUG_MALLOC', 1)


That would just turn off more debugging that we can actually provide without malloc_usable_size, i don't think this is what we want ?

do a git grep EINA_DEBUG_MALLOC

it appears in 2 files.

note that malloc_usable_size is a GNU extension

Thank you for pointing out how to search the repository, i still don't get what you are talking about.

If we do what you proposed above, then we are turning off debug code that works perfectly well without malloc_usable_size. This API is only used in eina_chained_mempool.c. The code arround it and the code in safepointer is *not* depending on malloc_usable_size, so why should we disable it if malloc_usable_size is not available ?

that's what is done in I first trust what is in it.

the macro is used in eo_ptr_indirection.x too, mprotect (non windows function) is used. It is called if HAVE_MMAP or HAVE_MMAN_H (can't remember) is defined. And HAVE_MMAP (or HAVE_MMAN_H) are available on Windows. If i defined these latter macro, I certainly will have problems (I actually have some problems, i tried)

so would you propose a change in the code instead ?

okay - but mprotect has nothing to do as far as i can see with malloc_usable_size. So i would rather add there a guard for if mprotect is available or not (Or emulate mprotect with VirtualProtect?)

zmike added a comment.Sep 3 2019, 12:00 PM

What's going on with this

mprotect is in evil now. i have to define HAVE_MMAP in evil_mman.h to check if there is no problem. I'll do that today

vtorri closed this task as Resolved.Sep 12 2019, 12:04 PM