Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSAN does not support C++ exceptions? #485

Open
ramosian-glider opened this issue Sep 1, 2015 · 11 comments
Open

TSAN does not support C++ exceptions? #485

ramosian-glider opened this issue Sep 1, 2015 · 11 comments

Comments

@ramosian-glider
Copy link
Member

Originally reported on Google Code with ID 78

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

Reported by andrew.c.morrow on 2014-09-30 15:26:55

@ramosian-glider
Copy link
Member Author

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

Reported by [email protected] on 2014-09-30 15:31:37

  • Status changed: Accepted
  • Labels added: Type-Enhancement, Priority-Later
  • Labels removed: Type-Defect, Priority-Medium

@ramosian-glider
Copy link
Member Author

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 :) 

Reported by konstantin.s.serebryany on 2014-09-30 16:09:29

@ramosian-glider
Copy link
Member Author

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

Reported by [email protected] on 2014-10-01 04:55:21

@ramosian-glider
Copy link
Member Author

FTR, there is patch for exceptions support in gcc in flight:
https://www.mail-archive.com/[email protected]/msg99353.html


Reported by [email protected] on 2014-12-16 09:27:08

@ramosian-glider
Copy link
Member Author

Just checking in on this feature request as it has been about 6 months. I still think
that this would be a very valuable addition to TSAN. Many C++ projects make use of
exceptions, and they currently cannot use TSAN.

Reported by andrew.c.morrow on 2015-06-23 21:52:52

@ramosian-glider
Copy link
Member Author

Hi Andrew,

No progress so far.
I've pinged the gcc patch thread (it does not seem to be landed).
I am also trying to sketch exception support in llvm, but it is not completely trivial:
http://reviews.llvm.org/D10740

Reported by [email protected] on 2015-06-27 14:54:45

@ramosian-glider
Copy link
Member Author

Adding Project:ThreadSanitizer as part of GitHub migration.

Reported by [email protected] on 2015-07-30 09:21:32

  • Labels added: ProjectThreadSanitizer

@morehouse
Copy link
Contributor

@dvyukov: Status?

@dvyukov
Copy link
Contributor

dvyukov commented Jun 7, 2018

No work was done on this. Still relevant.

@johnthagen
Copy link

Does [tsan] Add support for C++ exceptions into TSan (call __tsan_func_exit during unwinding) (merged Nov 2016) have any bearing on this?

@dvyukov
Copy link
Contributor

dvyukov commented Nov 11, 2020

@johnthagen good question. https://reviews.llvm.org/rL286893 looks like it added exception support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants