views:

269

answers:

2

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)
A: 

Appears to be fixed after upgrading to Boost 1.41.0. Thanks Nicolai.

Andy Faibishenko
+1  A: 

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.

Laurynas Biveinis