tor, 01.05.2003 kl. 07.26 skrev Gregory M. Turner:
(a) if the exception code runs, A() keeps running and eventually just returns... will it properly release all the stack from B(), C() and so on or is this a problem? I guess its OK since the SP just goes back to what it was when I called setjmp, right?
This would be OK.
(b) if the exception code doesn't run, A() runs longjmp again, to non-local goto /back/ into D(), using the second jmp_buf. This returns normally and would, I guess, expect to unwind the stack normally through C(), B() and so on... (this is all ignoring the fact that flow-of-control was interrupted by an exception, but for my purposes I don't think it matters).
This is not OK. Since the first setjmp releases all the stack frames between A and D, trying to later reclaim that released stack with another setjmp is doomed to unpredictable stack corruption.