How to handle exceptions in multithreading?

How to handle exceptions in multithreading?

Discussion between Spring developers.
Post Reply
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

How to handle exceptions in multithreading?

Post by jK » 14 Aug 2010, 10:40

Okay, after I got an offscreen OpenGL context & math syncing working in the multithreaded loadingstage, now comes the exceptions handling.

I modularized the exception handling, so now both the mainthread and the workerthreads use the same try..catch.

My problem is now if I just catch an exception in the workerthread, the mainthread hangs and shows a crash-report. So the solution is to quit all threads and to show the crash/content_error report in the mainthread. Doing so isn't easy AFAIK.
The only solution I see is too use execlp, but that would need a new binary (or new arguments for binary, so you can launch it to just display the error-report).

This seems a bit dirty, so are there better ways and how does GML handle this situations?
0 x

zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: How to handle exceptions in multithreading?

Post by zerver » 15 Aug 2010, 12:20

Why does the main thread hang and show a crash report? Hang I can understand (sync, barriers etc), but not the crash.

I would probably try to interrupt all other threads (makes them throw boost::thread_interrupted) in the exception handler and then let the threads exit cleanly while the main thread does some error output.
0 x

Post Reply

Return to “Dedicated Developer Discussion”

cron