开发者

Segmentation Fault in Boost Threads tls_destructor

开发者 https://www.devze.com 2022-12-15 05:27 出处:网络
I wrote a small app using the Boost asio example(3) of the multi-threaded HTTP server.Periodically I get a seg fault which occurs if I ctrl-c the app.I know I must be overwriting memory somewhere, but

I wrote a small app using the Boost asio example(3) of the multi-threaded HTTP server. Periodically I get a seg fault which occurs if I ctrl-c the app. I know I must be overwriting memory somewhere, but not really sure how to debug it. The stack trace in GDB is not helpful. Are there some tools in GCC that can help me detect the corruption prior to me hitting it in the dtor? (sorry, I am a Java guy mostly)

Thanks. Using Boost 1.38 on Debian Linux

PS Here is the stack trace


Program terminated with signal 11, Segmentation fault.
#0  0xb7f74389 in tls开发者_如何学运维_destructor (data=0xb5200fc8) at libs/thread/src/pthread/thread.cpp:86
86                                      thread_info->tss_data=current_node->next;
(gdb) where
#0  0xb7f74389 in tls_destructor (data=0xb5200fc8) at libs/thread/src/pthread/thread.cpp:86
#1  0xb7f75351 in thread_proxy (param=0xb5200fc8) at libs/thread/src/pthread/thread.cpp:142
#2  0xb7c03240 in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#3  0xb7dc049e in clone () from /lib/tls/i686/cmov/libc.so.6
(gdb)


Since this is a multithreaded program, there is a possibility that Boost upgrade only hid a real bug. I`d suggest having a test run using Valgrind Memcheck and Helgrind tools, in that order. The first one checks for memory-management problems, the second one for race conditions. IMHO a truly indispensable tool.

0

精彩评论

暂无评论...
验证码 换一张
取 消