<br><br><div class="gmail_quote">On Sun, Mar 6, 2011 at 7:37 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On Mar 6, 2011, at 11:01 AM, Talin wrote:<br>
> Here's an interesting problem - is it legal to copy the _Unwind_Exception struct to a different address in memory before calling _Unwind_Resume?<br>
><br>
> 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.<br>


<br>
</div>This is really a question about the Itanium EH ABI, so I'm not sure why you're asking it here.</blockquote><div><br></div><div>Only because I couldn't think of where else to ask :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

  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.<br>


<br></blockquote><div>Foreign exceptions would be in a different heap, so the garbage collector wouldn't attempt to move them or even be aware of their existence. I can see that there might be a problem if C++ code caught one of *my* exceptions which subsequently moved, although the exception wouldn't be moved until sometime after control passed back to my code, since the garbage collector only moves objects during safe points, and the foreign code wouldn't have safe point calls. This just means that people who call methods written in my language from other languages will have to be careful about exception handling.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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.<br>


<font color="#888888"><br></font></blockquote><div>That's not a problem, my code already does that.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<font color="#888888">
John.</font></blockquote></div><br><br clear="all"><br>-- <br>-- Talin<br>