fsgeek / finesse

Finesse Project Repository
Other
2 stars 0 forks source link

Crash during LD_PRELOAD library destructor #10

Closed fsgeek closed 4 years ago

fsgeek commented 4 years ago

Scenario: LD_PRELOAD on ls. Crashes:

(gdb) bt

0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51

1 0x00007ffff75e5801 in __GI_abort () at abort.c:79

2 0x00007ffff75d539a in __assert_fail_base (fmt=0x7ffff775c7d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",

assertion=assertion@entry=0x7ffff7bcb917 "fd_lookup_table", file=file@entry=0x7ffff7bcb900 "../finesse/api/fdmgr.c", line=line@entry=291, 
function=function@entry=0x7ffff7bcb970 <__PRETTY_FUNCTION__.7421> "finesse_lookup_file_state") at assert.c:92

3 0x00007ffff75d5412 in __GI___assert_fail (assertion=0x7ffff7bcb917 "fd_lookup_table", file=0x7ffff7bcb900 "../finesse/api/fdmgr.c", line=291,

function=0x7ffff7bcb970 <__PRETTY_FUNCTION__.7421> "finesse_lookup_file_state") at assert.c:101

4 0x00007ffff7bc9961 in finesse_lookup_file_state (fd=6) at ../finesse/api/fdmgr.c:291

5 0x00007ffff7bc2efb in finesse_close (fd=6) at ../finesse/api/openclose.c:249

6 0x00007ffff7bc159c in close (fd=6) at ../finesse/preload/close.c:10

7 0x00007ffff7bc4f1d in CleanupClientConnectionState (ccs=0x555555787a30) at ../finesse/communications/fcc.c:24

8 0x00007ffff7bc5533 in FinesseStopClientConnection (FinesseClientHandle=0x555555787a30) at ../finesse/communications/fcc.c:130

9 0x00007ffff7bc1cff in finesse_real_shutdown () at ../finesse/api/init.c:77

10 0x00007ffff7bc15c1 in finesse_preload_deinit () at ../finesse/preload/init.c:22

11 0x00007ffff7de5b73 in _dl_fini () at dl-fini.c:138

12 0x00007ffff75e8041 in run_exit_handlers (status=0, listp=0x7ffff7990718 <exit_funcs>, run_list_atexit=run_list_atexit@entry=true,

run_dtors=run_dtors@entry=true) at exit.c:108

13 0x00007ffff75e813a in __GI_exit (status=) at exit.c:139

---Type to continue, or q to quit---

14 0x00007ffff75c6b9e in __libc_start_main (main=0x555555557e90, argc=2, argv=0x7fffffffe0c8, init=, fini=,

rtld_fini=<optimized out>, stack_end=0x7fffffffe0b8) at ../csu/libc-start.c:344

15 0x000055555555987a in ?? ()

This looks like an ordering issue - we've torn down the table, but we're still trying to use it.

fsgeek commented 4 years ago

Seems to happen for touch as well.

fsgeek commented 4 years ago

This was a termination ordering issue - the preload code called close when we were cleaning up resources. Solution was to move the close to before I cleaned up the file descriptor map table.