[LLVMdev] _Unwind_Exception and _Unwind_Resume

John McCall rjmccall at apple.com
Sun Mar 6 19:37:46 PST 2011


On Mar 6, 2011, at 11:01 AM, Talin wrote:
> Here's an interesting problem - is it legal to copy the _Unwind_Exception struct to a different address in memory before calling _Unwind_Resume?
> 
> I'm thinking of the scenario in which a garbage collection run is triggered in the middle of a "finally" block. If it's a copying collector, it might relocate the exception object, which has the _Unwind_Exception structure embedded in the middle of it. I don't see why this wouldn't work, but I thought I'd ask around to be sure.

This is really a question about the Itanium EH ABI, so I'm not sure why you're asking it here.  That said, the ABI does not permit you to move exception objects in general, because even if you're working in a language where every object can be trivially moved, any given exception might be a "foreign" exception from a language (like C++) which does not provide this guarantee.

Also, the ABI basically requires the EH implementation to internally maintain references to active exception objects under certain circumstances;  you'll need to treat those as GC roots, which means hard-coding knowledge of the implementation into your collector / runtime.

John.



More information about the llvm-dev mailing list