c++ - Segmentation fault while calling malloc and program in deadlock futex -


the code working on has lot of calls create new strings , stuff.. after upgrading servers 12.10 ubuntu, have started facing troubles. of child processes stuck in futex. went , attached gdb running process in futex long time, did backtrace , found following logs

#0  0x00007f563afc69bb in ?? () /lib/x86_64-linux-gnu/libc.so.6 #1  0x00007f563af4a221 in ?? () /lib/x86_64-linux-gnu/libc.so.6 #2  0x00007f563af47fa7 in malloc () /lib/x86_64-linux-gnu/libc.so.6 #3  0x00007f563afcfbfa in backtrace_symbols () /lib/x86_64-linux-gnu/libc.so.6 #4  0x0000000000446945 in sig_segv (signo=<optimized out>) @ file has handler,sighandler #5  <signal handler called> #6  0x00007f563aefb425 in raise () /lib/x86_64-linux-gnu/libc.so.6 #7  0x00007f563aefeb8b in abort () /lib/x86_64-linux-gnu/libc.so.6 #8  0x00007f563af3939e in ?? () /lib/x86_64-linux-gnu/libc.so.6 #9  0x00007f563af43b96 in ?? () /lib/x86_64-linux-gnu/libc.so.6 #10 0x00007f563af463e8 in ?? () /lib/x86_64-linux-gnu/libc.so.6 #11 0x00007f563af47fb5 in malloc () /lib/x86_64-linux-gnu/libc.so.6 #12 0x00007f563b7f660d in operator new(unsigned long) () /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #13 0x00007f563b8533b9 in std::string::_rep::_s_create(unsigned long, unsigned long, std::allocator<char> const&) ()    /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #14 0x00007f563b854d95 in char* std::string::_s_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) () /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #15 0x00007f563b854e73 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) () /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #16 0x0000000000412362 in mystring (bs=0x4aabd6 "-", this=0x7fffe854f940) @ constructor c-string mystring(const char* bs):std::string(bs) {}; #17 function calls above line 

i confused. checked memory, , pc had 20gb free ram memory. chances function crashes in malloc? why stuck in futex, why malloc? love explanation this.

the crash happens after called :

    mystring(const char* bs):std::string(bs) {}; 

this line called convert simple c-string c++ type std::string. class own. unable give entire code here due 2 reasons. 1) code owned company. 2) damn long.

i sorry. need explanation why crash in malloc , hence causing deadlock because sighandler calls malloc , waits previous lock release, not.

it looks might calling malloc() (indirectly, through backtrace_symbols()) in signal handler, don't.

malloc() not async-signal safe. calling inside signal handler while other code in malloc() deadlock (as did here).

use backtrace_symbols_fd() instead, won't call malloc()


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -