On Feb 1, 2012, at 10:12 AM, Howard Hinnant wrote: > Getting back to a good question asked by Sebastian. > > A foreign exception is one that is caught by this library (maybe just > temporarily to do a clenaup, maybe permanently), but was not thrown by this > library. If an exception is not thrown by this library then __cxa_throw was > never called for it, at least not this library's implementation of it. > > __cxa_throw, among other things, alters data in the thread-local > __cxa_eh_globals data structure: it increments the number of uncaught > exceptions. This is later decremented in __cxa_begin_catch. And the > thread-local __cxa_eh_globals data structure is also allocated and provided > by this library. Even if another library provides a thread-local > __cxa_eh_globals data structure, it is not going to be the same one that this > library provides. > > Because of this, I've come to the conclusion that if two Itanium libraries > are active at the same time within an application, they should treat each > other's exceptions as foreign. This will mean sometimes an exception is > unexpectedly caught or not caught. But trying to do anything else is just > going to lead to more subtle bugs such as std::uncaught_exception() > sporadically returning the wrong answer. Really two different libc++abi's > active at the same time in the same application is just a recipe for disaster > no matter what (as far as I can figure out). > > I'm about to make the detection of two C++ runtimes stronger: I'm going to > call anything that doesn't have one of the exceptions we generate foreign, > even if it is a C++ exception, even one with an __cxa_exception header. And > I believe there's no way to be link-compatible with a GCC runtime by using > the GCC vendor id. Doing so would hide, instead of more readily expose the > fact that two C++ runtimes are active. > > I'm open to discussion on this point. And as I write this, libc++abi is not > currently consistent with what I'm writing. But unless there are objections, > I'm about to make it so.
Sounds good to me. I very much prefer obvious failures to subtle ones. -- Marshall Marshall Clow Idio Software <mailto:[email protected]> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait). -- Yu Suzuki _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
