This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug malloc/22050] New: Linking with -lmcheck does not hook __malloc_initialize_hook correctly


https://sourceware.org/bugzilla/show_bug.cgi?id=22050

            Bug ID: 22050
           Summary: Linking with -lmcheck does not hook
                    __malloc_initialize_hook correctly
           Product: glibc
           Version: 2.26
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: malloc
          Assignee: unassigned at sourceware dot org
          Reporter: mo at mightym0 dot de
  Target Milestone: ---

Created attachment 10378
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10378&action=edit
Example code

I tested this with the 2.26 release as well as the latest HEAD of master
8325b477b1
GCC: gcc version 7.1.1 20170630 (GCC)

When linking with -lmcheck, the mcheck initialization should be triggered by
storing the address of turn_on_mcheck into the symbol __malloc_initialize_hook.
This symbol is checked by ptmalloc_init and called if present. However,
what happens when I try to link with -lmcheck, is a symbol is placed into the
binary's data section called "__malloc_initialize_hook". This symbol contains
the address of turn_on_mcheck. But when ptmalloc_init checks for the
__malloc_initialize_hook, it checks the actual symbol in the libc not in the
binary, so essentially the symbol exists twice and mcheck is never initialized.

At this point I'm pretty confused why this happens. The
__malloc_initialize_hook is defined in malloc-hooks.h and should be exported,
so I don't see why the duplicate symbol in the binary even exists.

It's very likely that I'm wrong and did some fundamental mistake,
but at this point I can't figure out what's wrong and hope that somebody either
spots a bug or my mistake.


Thank you
Moritz

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]