Exception occurred in "boost::thread" cannot be caught by vs.net.
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? thanks.
tricycle@gmail.com 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.
On 9/15/05, Ben Hutchings
[snip]. 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.
Sorry if it is too obvious, but how do I do that?
Ben.
Thanks, -- Felipe Magno de Almeida Developer from synergy and Computer Science student from State University of Campinas(UNICAMP). Unicamp: http://www.ic.unicamp.br Synergy: http://www.synergy.com.br "There is no dark side of the moon really. Matter of fact it's all dark."
In VS.net, go to the Debug menu item, and select Exceptions... You will get a dialog box that allows you to select how you want exceptions handled. There is a tree view that shows a hierarchy of both win32 exceptions and C++ exceptions, and you can choose to break into the debugger at the time the exception is thrown, or only if it is not handled by the application. You can either set it for individual exceptions, or for entire classes of exceptions. Cheers, tim On Sep 15, 2005, at 12:35 PM, Felipe Magno de Almeida wrote:
On 9/15/05, Ben Hutchings
wrote: [snip]. 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.
Sorry if it is too obvious, but how do I do that?
Ben.
Thanks, -- Felipe Magno de Almeida Developer from synergy and Computer Science student from State University of Campinas(UNICAMP). Unicamp: http://www.ic.unicamp.br Synergy: http://www.synergy.com.br "There is no dark side of the moon really. Matter of fact it's all dark."
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Thank you Timothy Ritchey. -- Felipe Magno de Almeida Developer from synergy and Computer Science student from State University of Campinas(UNICAMP). Unicamp: http://www.ic.unicamp.br Synergy: http://www.synergy.com.br "There is no dark side of the moon really. Matter of fact it's all dark."
participants (4)
-
Ben Hutchings
-
Felipe Magno de Almeida
-
Timothy Ritchey
-
蹬三轮的