RE: [GD-Linux] signals and exceptions
Brought to you by:
vexxed72
From: Daniel V. <vo...@ep...> - 2001-11-14 20:26:02
|
> The underlying memory violation is part of the glibc libraries, and does > not originate from the application itself, so a general means of > converting to an exception won't happen. How you deal with it might > depend on whether you are using threads or not. In the case of threads, > you'd mask all but one thread to not catch signals; likely the main > thread would do signal handling. Regardless, you do not want to mix > signal handling with exceptions without being very careful. So one > question is whether you are using threads, and a second question is what > you want to do when this signal is sent...can you live with abandoning > the current thread or function? I see you're trying to catch and work > with the exception within the sample function (which is just main() in > this case), but in actual use, will that be needed? You could create a > global or per-thread state object, have your signal handler set this, > and instead of try/catch, just have your blocks: > { // NOTE: no "try". > ...general stuff that might have SIGSEGV... > // if something goes wrong, signal handler sets oSigState. > } > oSigState.mRethrow(); > > (where rethrow() does nothing if a mapping does not exist between a > particular signal and a substitute exception; you could take it further > and allow specification of signals, e.g., oSigState.mRethrow(SIGSEGV), > which would ignore any signal state other than SIGSEGV) > > It depends a lot on what you want to accomplish and whether you are > using threads. We just use exceptions to print out a meaningful stack backtrace when the game crashes and it relies on unwinding the stack as every function has it's name in ASCII on the stack. Thanks for all your suggestions (D.Stimits, Mark Collins) - I'll look into this a bit further and let you know how it goes. I finally want to get rid of all the ugly code in the Linux code and this and Unicode support are the two things on my plate. > My "reply-to" button just lists your address, not the list. Plus, I'm > subscribed to the gd algo and opengl lists, and this is arriving and > being sent to my general sourceforge box, since I don't have a rule for > general "gamedevlists-linux" (I should, I love linux game dev, it's > about all I do). I'll simply keep sending my replies to the list. > D. Stimits, st...@id... - Daniel Vogel, Programmer, Epic Games Inc. |