Boost logo

Boost Users :

From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2005-09-15 08:45:05


tricycle_at_[hidden] wrote:

>When an "access violation" exception occurred and didn't be caught by
>the program, it would be caught by debugger such like vs.net.
>
>1: int main()
>2: {
>3: int *i = 0;
>4: *i = 1;
>5: }
>
>If I debug this program in vs.net, program will be broken at line 4
>and an exception dialog box will be displayed. So I can know the
>origin of the exception.
>
>The problem is when the exception occurred in the thread started by
>boost::thread, program cannot be broken at the line from which
>exception been thrown.
>
>01: void func()
>02: {
>03: int *i = NULL;
>04: *i = 1;
>05: }
>
>06: int _tmain(int argc, _TCHAR* argv[])
>07: {
>08: thread *t = new thread(func);
>10: t->join();
>11: delete t;
>12: return 0;
>13: }
>
>The program should be broken at line 4, but it didn't. This makes the
>debugging boost::thread more difficult. How can I resolve the problem?
>
>
Currently the boost::thread entry wrapper function catches and discards
exceptions (this is a design error IMNSHO). This combines with the VC++
behaviour of treating all Win32 structured exceptions as anonymous C++
exceptions to hide access violations and similar errors in threads
started with boost::thread. You can avoid this by configuring the Visual
Studio debugger to break when a Win32 exception is thrown, rather than
only if it is unhandled.

Ben.


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