rui314 / mold

Mold: A Modern Linker 🦠
MIT License
14.34k stars 470 forks source link

mold miss apply relocation for std::deque<int, std::allocator<int> >::~deque() #855

Open coreyzzp opened 1 year ago

coreyzzp commented 1 year ago

it happens randomly in our big code base, the executable linked by mold is core in following corestack:

#0  0x0000000000000000 in ?? ()
#1  0x00000000005d0e96 in std::deque<int, std::allocator<int> >::~deque (this=0x7ffe533e6420, __in_chrg=<optimized out>) at /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/stl_deque.h:918
#2  0x00000000005d0956 in CLogCircleQueue<TagLogNode, (unsigned short)4096>::CLogCircleQueue (this=0x9bbcb28 <G_PlayerLog+328>) at /LogDataStruct.hpp:438
#3  0x00000000011a1b67 in CMultiFileLogData::CMultiFileLogData (this=0x9bbc9e0 <G_PlayerLog>) at /LogDataStruct.hpp:508
#4  0x00000000011a1835 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at /LogDataStruct.cpp:7
#5  0x00000000011a197c in _GLOBAL__sub_I_LogDataStruct.cpp(void) () at /LogDataStruct.cpp:17
#6  0x00000000011cd45d in __libc_csu_init ()
#7  0x00007f2e98df7b95 in __libc_start_main (main=0x560846 <main(int, char**)>, argc=1, ubp_av=0x7ffe533e6638, init=0x11cd410 <__libc_csu_init>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe533e6628) at ../csu/libc-start.c:233
#8  0x0000000000211ae9 in _start ()

the dissamble of std::deque<int, std::allocator<int> >::~deque() is like this:

image

the line looks like not being relocated to the right address

   0x00000000005d0e91 <+111>:   callq  0x0

while another executable in the same code base like this:

image
   0x000000000067b8f5 <+111>:   callq  0x67bc1e <std::_Deque_base<int, std::allocator<int> >::~_Deque_base()>

I am not able to make a smallest prove of concept yet

coreyzzp commented 1 year ago

mold 1.5.1 (1ed941f3f0c3a7e55ba5d34a9f9f0fe7f67cb90d; compatible with GNU ld)

rui314 commented 1 year ago

It's hard to debug it without reproducing it locally. If it's open source, please let me know the location of your repo. If not, you can share me object files with me privately.