https://bugs.kde.org/show_bug.cgi?id=432510

Mark Wielaard <m...@klomp.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m...@klomp.org

--- Comment #1 from Mark Wielaard <m...@klomp.org> ---
This is a nice idea.

One tricky thing is that although the malloc-like functions can return NULL
they don't actually set errno. See https://bugs.kde.org/show_bug.cgi?id=217695
this may or may not be a problem for this idea.

There is a brief description on how the malloc replacement functions work at
./docs/internals/m_replacemalloc.txt

I am not sure what the right "level" is to implement this.
The choices are:

- ./coregrind/m_replacemalloc/vg_replace_malloc.c
  This is where the malloc-like functions are intercepted.
  The code runs as part of the program (is LD_PRELOADED). Which means you
  cannot easily call into the valgrind core. But you can simply replace
  any malloc-like call with a (random) return of NULL which would then
  work with any valgrind tool that uses malloc replacement.

- In a specific tool like in memcheck/mc_malloc_wrappers.c
  See the VG_(needs_malloc_replacement) call in memcheck/mc_main.c
  to see which malloc like functions are wrapped
  (MC_(malloc), MC_(calloc), MC_(realloc), etc.) most of these
  call into MC_(new_block). Which you could conditionally return NULL
  based on the tool (memcheck in this case) state.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to