[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libunwind] Signal handlers and unw_resume
From: |
David Mosberger |
Subject: |
Re: [libunwind] Signal handlers and unw_resume |
Date: |
Mon, 23 Aug 2004 04:14:19 -0700 |
>>>>> On Mon, 23 Aug 2004 11:55:05 +0100, "Thomas Hallgren" <address@hidden>
>>>>> said:
Thomas> I have a question on doing a unw_resume from within a signal
Thomas> handler. I do the following:
Thomas> I call unw_getcontext() from within a signal handler
Thomas> followed by an unw_init_local() and a number of unw_step()
Thomas> calls to take me passed the signal frame and to the point
Thomas> where the code was interrupted. After some local processing
Thomas> I then call unw_resume() just prior to where the signal
Thomas> handler return would be.
Thomas> Then it struck me. Using this approach I effectively skip
Thomas> any clean-up processing that normally would occur in the
Thomas> caller of the signal handler. Is that a problem? Or is it an
Thomas> unspoken law that such processing should never occur in a
Thomas> well written OS?
I think it's a can of worms. Enough so that there is a regular
setjmp() and a setjmp_unwind() (defined by C++ ABI). The former
doesn't do any cleanups, whereas the latter does. Your situation
sound similar.
Note that NPTL takes advantage of C cleanup handlers so the problem is
not limited to C++ (other other languages with exception handling).
I suspect it would be safer (but also much slower), to invoke handlers
if you encounter them during unwinding.
--david