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 »

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?
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: How to handle exceptions in multithreading?

Post by zerver »

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.
Post Reply

Return to “Dedicated Developer Discussion”