Boost logo

Boost Users :

Subject: Re: [Boost-users] [Thread] Interrupting a thread causes a segmentation fault
From: W Frane (molluskadvertising_at_[hidden])
Date: 2011-02-17 11:32:47


> From: Viatcheslav.Sysoltsev_at_[hidden]
> Date: Thu, 17 Feb 2011 09:42:53 +0100
> Subject: Re: [Boost-users] [Thread] Interrupting a thread causes a segmentation fault
>
> I believe the test programm is all right, it works well with boost 1.36
> and 1.45 on linux with gcc 4.3.2 with both dynamic and static boost
> linkage. Check out the stack trace at the moment of failure, it shall give
> good insight into kind of problem.
>
> -- Slava

I ran the debugger and took a look at the output at the point of the fault. Unfortunately, I didn't find it particularly enlightening, although it seems clear that the fault is occurring when the thread_interrupted exception is thrown by the Boost Thread library.

In case it might be useful, I've included the information from the debugger below, as well as an excerpt from thread.cpp containing the function in which the fault occurs (to save anyone reading this the time of going to check the source).

Any suggestions as to what might be the problem here would be appreciated; I also should note that I'm using Windows XP, so it may be an issue with the Windows API since the program apparently runs fine on Linux.

Thanks,

William

CALL STACK
=============================================================================
#0 00000000    0x00406410 in __cxa_throw() (??:??)
#1 00403070    boost::this_thread::interruption_point() (libs\thread\src\win32\thread.cpp:495)
#2 00401359    testingThread() (C:\Documents and Settings\WFrane\My Documents\C++ code\boost thread interrupt test\boost_thread_interrupt_test\main.cpp:12)
#3 00422666    boost::detail::thread_data<void (*)() (C:/Program Files/boost/boost_1_45_0/boost/thread/detail/thread.hpp:61)
#4 00401BFF    thread_start_function(param=0x243198) (libs\thread\src\win32\thread.cpp:171)
#5 77C3A3B0    msvcrt!_endthreadex() (C:\WINDOWS\system32\msvcrt.dll:??)
#6 7C80B729    KERNEL32!GetModuleFileNameA() (C:\WINDOWS\system32\kernel32.dll:??)
#7 00000000    0x00000000 in ??() (??:??)
=============================================================================

CURRENT STACK FRAME
=============================================================================
Stack level 1, frame at 0x78fe68:
 eip = 0x403070 in boost::this_thread::interruption_point() (libs\thread\src\win32\thread.cpp:495); saved eip 0x401359
 called by frame at 0x78fef8, caller of frame at 0x78fe48
 source language c++.
 Arglist at 0x78fe60, args:
 Locals at 0x78fe60, Previous frame's sp is 0x78fe68
 Saved registers:
  ebp at 0x78fe60, eip at 0x78fe64
=============================================================================

DISASSEMBLY
=============================================================================
Frame function: boost::this_thread::interruption_point() (libs\thread\src\win32\thread.cpp:495)
Frame address : 0078FE68
--------------------------------------------------------------------------------
0040300D    push   %ebp
0040300E    mov    %esp,%ebp
00403010    sub    $0x18,%esp
00403013    call   0x403072 <boost::this_thread::interruption_enabled()>
00403018    test   %al,%al
0040301A    je     0x403029 <boost::this_thread::interruption_point()+28>
0040301C    call   0x403095 <boost::this_thread::interruption_requested()>
00403021    test   %al,%al
00403023    je     0x403029 <boost::this_thread::interruption_point()+28>
00403025    mov    $0x1,%al
00403027    jmp    0x40302b <boost::this_thread::interruption_point()+30>
00403029    mov    $0x0,%al
0040302B    test   %al,%al
0040302D    je     0x403070 <boost::this_thread::interruption_point()+99>
0040302F    call   0x40184c <get_current_thread_data>
00403034    add    $0xc,%eax
00403037    mov    %eax,(%esp)
0040303A    call   0x4280dc <boost::detail::win32::handle_manager::operator void*() const>
0040303F    mov    %eax,(%esp)
00403042    mov    0x488298,%eax
00403047    call   *%eax
00403049    sub    $0x4,%esp
0040304C    movl   $0x1,(%esp)
00403053    call   0x405e8c <__cxa_allocate_exception>
00403058    movl   $0x0,0x8(%esp)
00403060    movl   $0x47ccec,0x4(%esp)
00403068    mov    %eax,(%esp)
0040306B    call   0x40640c <__cxa_throw>
00403070    leave
00403071    ret
=============================================================================

SOURCE FOR boost::this_thread::interruption_point() (lines 490-497 of boost\boost_1_45_0\libs\thread\src\win32\thread.cpp)
=============================================================================
void interruption_point()
        {
            if(interruption_enabled() && interruption_requested())
            {
                detail::win32::ResetEvent(get_current_thread_data()->interruption_handle);
                throw thread_interrupted();
            }
        }
=============================================================================
                                               


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net