theRockLiu / thread-sanitizer

Automatically exported from code.google.com/p/thread-sanitizer
0 stars 0 forks source link

TSAN does not support C++ exceptions? #78

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
According to the wiki documentation, C++ exceptions are not supported: 
https://code.google.com/p/thread-sanitizer/wiki/CppManual#FAQ

While I understand that exception support is not something that Google would be 
particularly interested in given the style guide, exceptions are widely used in 
other C++ codebases that could benefit from ThreadSanitizer.

If the restriction in the documentation is no longer correct, please update the 
docs. If the restriction is still in place, please add support for C++ 
exceptions. I'd also be interested in some details on what would be required to 
implement support or what the obstacles doing so currently are.

Thanks,
Andrew

Original issue reported on code.google.com by andrew.c.morrow@gmail.com on 30 Sep 2014 at 3:26

GoogleCodeExporter commented 9 years ago
Tsan would need to intercept control flow associated with exceptions. Namely, 
when an exception is thrown and to what frame is transfers control.

Original comment by dvyu...@google.com on 30 Sep 2014 at 3:31

GoogleCodeExporter commented 9 years ago
We'll need a kind of RAII for tsan entry/exit hooks. 
When we are adding tsan instrumentation, we need to create a fake class object 
with a ctor and dtor. dtor will be called whenever we leave the function, even 
if there was an exception.
It is already too late to do that during the current tsan phase, we'll need a 
special pass in the frontend (clang). 
I'd love this to happen but this is nowhere near our top priorities for now. 
Help is always welcome :) 

Original comment by konstant...@gmail.com on 30 Sep 2014 at 4:09

GoogleCodeExporter commented 9 years ago
> We'll need a kind of RAII for tsan entry/exit hooks. 

If that would be simpler to implement, tsan can simply "rewind" state to a 
given frame. So at the throw site we just need to know destination frame; or, 
alternatively, intercept catch and rewind state to the current frame. I use 
this machinery in longjmp support, no compiler changes were needed.

Original comment by dvyu...@google.com on 1 Oct 2014 at 4:55

GoogleCodeExporter commented 9 years ago
FTR, there is patch for exceptions support in gcc in flight:
https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg99353.html

Original comment by dvyu...@google.com on 16 Dec 2014 at 9:27