You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(gdb) where
#0 0xffff808868a96e0e in ?? ()
#1 0x00007f7797984c17 in _dl_fini () at dl-fini.c:235
#2 0x00007f7796720fe8 in __run_exit_handlers (status=0, listp=0x7f7796aaa5f8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
#3 0x00007f7796721035 in __GI_exit (status=<optimized out>) at exit.c:104
#4 0x00007f7796707837 in __libc_start_main (main=0x409c31 <main()>, argc=1, argv=0x7ffe2f6cd6f8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe2f6cd6e8) at ../csu/libc-start.c:325
#5 0x0000000000409b19 in _start ()
I'm running glibc-2.23:
$ /lib/x86_64-linux-gnu/libc.so.6
GNU C Library (Ubuntu GLIBC 2.23-0ubuntu3) stable release version 2.23, by Roland McGr
215/* Is there a destructor function? */216if (l->l_info[DT_FINI_ARRAY] !=NULL217||l->l_info[DT_FINI] !=NULL)
218 {
219/* When debugging print a message first. */220if (__builtin_expect (GLRO(dl_debug_mask)
221&DL_DEBUG_IMPCALLS, 0))
222_dl_debug_printf ("\ncalling fini: %s [%lu]\n\n",
223DSO_FILENAME (l->l_name),
224ns);
225226/* First see whether an array is given. */227if (l->l_info[DT_FINI_ARRAY] !=NULL)
228 {
229ElfW(Addr) *array=230 (ElfW(Addr) *) (l->l_addr231+l->l_info[DT_FINI_ARRAY]->d_un.d_ptr);
232unsigned inti= (l->l_info[DT_FINI_ARRAYSZ]->d_un.d_val233 / sizeof (ElfW(Addr)));
234while (i-->0)
235 ((fini_t) array[i]) (); // this is the line that seg faults236 }
237
If I change TestAPI::work to actually call socket, then it works fine
Shared library does nothing:
Here I hook the
socket
function inTestAPI
:Running it seg faults:
GDB stack trace:
I'm running
glibc-2.23
:According to the glibc source
If I change
TestAPI::work
to actually callsocket
, then it works fineRunning now uses the hooked
socket
function, and no seg faultIs there a way to hook functions that may not be called in the shared library, and not have the app seg fault?
The text was updated successfully, but these errors were encountered: