[cfe-dev] Any known issues with libc++ exceptions and cross-thread exception propagation?

Howard Hinnant hhinnant at apple.com
Sat Jul 21 11:06:49 PDT 2012

On Jul 21, 2012, at 1:10 PM, Joe Groff <arcata at gmail.com> wrote:

> Hi everyone. I'm working on getting Intel's Thread Building Blocks
> library to compile and run with libc++ on Mac OS X 10.7. I have it
> mostly working, but I'm seeing sporadic failures in its test suite
> related to the library's exception propagation features. In
> particular, exceptions appear occasionally not to get thrown when
> expected, and occasionally appear with the wrong type_info. My
> attempts at printf debugging however seem to make the problems go away
> entirely, so I think there might be threading heisenbugs at fault
> here. Before investigating deeper, I wanted to ask first if there are
> any known issues with libc++ that would cause problems with passing
> exceptions between threads. Is libc++'s exception_ptr implementation
> not properly thread safe yet, or are there any other potential
> gotchas? TBB currently tries to use the obsolete draft function
> "copy_exception" instead of the final standard "make_exception_ptr" to
> capture exception objects; are there semantic differences between the
> draft and final interfaces that could cause problems?
> For reference, here's the current state of the patch against Threading
> Building Blocks 4.0 Update 5 I'm working with:
> https://gist.github.com/3154264
> Thanks for any help!
> -Joe

Hi Joe,

The exception_ptr implementation on Lion uses atomics (__sync_add_and_fetch) to manage the reference count underlying exception_ptr, so that copying it should be thread safe.  Offhand I can't immediately think of any known issues that would result in the symptoms you're describing.

I was under the impression that make_exception_ptr shipped on Lion and that copy_exception did not.  Though I could be mistaken.  But there should be no semantic difference between the two.


More information about the cfe-dev mailing list