This is the mail archive of the libc-alpha@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]

question on glibc interposition


I have a question on glibc interposition.   Should calls to an
interposed function (e.g., malloc) from within a shared library
(e.g., libgfortran.so) bind to the interposing library, as opposed
to the glibc version?

For example I have a library that interposes malloc/free/etc. and am
finding cases in the Fortran runtime library libgfortran.so for which the
answer to the above question is “no”:

(gdb) where
#0  __GI___libc_malloc (bytes=5) at malloc.c:3030
#1  0x00007ffff76bdc28 in ?? () from /lib64/libgfortran.so.3
#2  0x00007ffff7799f5d in _gfortran_string_trim () from /lib64/libgfortran.so.3
#3  0x000000000046c083 in __textfile_module_MOD_open_for_read ()
#4  0x000000000046cf38 in __textfile_module_MOD_open_1 ()
#5  0x00000000004023b2 in main ()
(gdb) ^Z
Suspended
(xen.x86_64)% ps
  PID TTY          TIME CMD
  556 pts/1    00:00:00 ps
29977 pts/1    00:00:00 tcsh
32580 pts/1    00:00:00 gdb
32645 pts/1    00:00:00 tonto_base.glib
(xen.x86_64)% ldd tonto_base.glibc_mmheap 
	linux-vdso.so.1 =>  (0x00007ffd4b69d000)
	libmmheap_malloc.so.1 => /home/caoki/work/glibc/proto/lib64/libmmheap_malloc.so.1 (0x00007efeef3e5000)
	libmmheap.so.1 => /home/caoki/work/glibc/proto/lib64/libmmheap.so.1 (0x00007efeef1d4000)
	libgfortran.so.3 => /lib64/libgfortran.so.3 (0x00007efeeee9d000)
	libm.so.6 => /home/caoki/work/glibc/proto/lib64/libm.so.6 (0x00007efeeeb0b000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007efeee8f4000)
	libquadmath.so.0 => /lib64/libquadmath.so.0 (0x00007efeee6b8000)
	libc.so.6 => /home/caoki/work/glibc/proto/lib64/libc.so.6 (0x00007efeee305000)
	/home/caoki/work/glibc/proto/lib64/ld-2.26.9000.so => /lib64/ld-linux-x86-64.so.2 (0x00005574b1671000)
(xen.x86_64)% nm  /home/caoki/work/glibc/proto/lib64/libmmheap_malloc.so.1 | grep -w T
00000000000011d0 T aligned_alloc
0000000000000e90 T calloc
0000000000000f40 T free
0000000000000e00 T malloc
0000000000000f50 T memalign
0000000000001170 T posix_memalign
0000000000001000 T realloc
(xen.x86_64)% 

The problem is that in other cases in the same process, e.g., in
the main program, calls to malloc/free/etc are bound to the interposition
library.   This doesn’t work well when a block allocated by glibc malloc
is passed to the interposition library’s version of free().

Any clues appreciated.   I will gladly supply additional information 
if requested.

-chris


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