-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add multithread support to ASan #9076
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a question about the tests
@@ -3911,6 +3911,19 @@ def test_pthread_tls_main(self): | |||
def test_pthread_lsan(self, name, args=[]): | |||
self.btest(path_from_root('tests', 'pthread', name + '.cpp'), expected='1', args=['-fsanitize=leak', '-s', 'TOTAL_MEMORY=256MB', '-s', 'USE_PTHREADS', '-s', 'PROXY_TO_PTHREAD', '-std=c++11', '--pre-js', path_from_root('tests', 'pthread', name + '.js')] + args) | |||
|
|||
@parameterized({ | |||
'leak': ['test_pthread_lsan_leak', ['-g4']], | |||
'no_leak': ['test_pthread_lsan_no_leak'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lsan
->asan
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. We are reusing the test_pthread_lsan* for ASan. I'll add a comment to say this is not an error.
EMSCRIPTEN_KEEPALIVE | ||
__attribute__((constructor(99))) // This must run before any userland ctors | ||
__attribute__((constructor(0))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this we had 99 and 100, so there was an order, but this changes them both to 0 - isn't that wrong? I think we need to change asan's priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two constructors don't actually depend on each other. We only thought they did due to pthread_cleanup
, but as it turns out, pthread_cleanup
is purely JavsScript and does not care if the C side has been initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. However, I think it would be safer going forward to have a definite order there - I can see us adding more stuff to one of the constructors some day, and having flaky failures because the order is nondeterministic. So I think it's worth changing asan's priority, keeping all three in a clear order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff to change ASan's priority: https://reviews.llvm.org/D65684
Summary: This change gives Emscripten the ability to use more than one constructor priorities that runs before ASan. By convention, constructor priorites 0-100 are reserved for use by the system. ASan on Emscripten now uses priority 50, leaving plenty of room for use by Emscripten before and after ASan. This change is done in response to: emscripten-core/emscripten#9076 (comment) Reviewers: kripken, tlively, aheejin Reviewed By: tlively Subscribers: cfe-commits, dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D65684 llvm-svn: 368101
Summary: This change gives Emscripten the ability to use more than one constructor priorities that runs before ASan. By convention, constructor priorites 0-100 are reserved for use by the system. ASan on Emscripten now uses priority 50, leaving plenty of room for use by Emscripten before and after ASan. This change is done in response to: emscripten-core/emscripten#9076 (comment) Reviewers: kripken, tlively, aheejin Reviewed By: tlively Subscribers: cfe-commits, dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D65684 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368101 91177308-0d34-0410-b5e6-96231b3b80d8
Summary: This change gives Emscripten the ability to use more than one constructor priorities that runs before ASan. By convention, constructor priorites 0-100 are reserved for use by the system. ASan on Emscripten now uses priority 50, leaving plenty of room for use by Emscripten before and after ASan. This change is done in response to: emscripten-core/emscripten#9076 (comment) Reviewers: kripken, tlively, aheejin Reviewed By: tlively Subscribers: cfe-commits, dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D65684 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368101 91177308-0d34-0410-b5e6-96231b3b80d8
Summary: This change gives Emscripten the ability to use more than one constructor priorities that runs before ASan. By convention, constructor priorites 0-100 are reserved for use by the system. ASan on Emscripten now uses priority 50, leaving plenty of room for use by Emscripten before and after ASan. This change is done in response to: emscripten-core/emscripten#9076 (comment) Reviewers: kripken, tlively, aheejin Reviewed By: tlively Subscribers: cfe-commits, dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D65684 git-svn-id: http://llvm.org/svn/llvm-project/cfe/trunk@368101 91177308-0d34-0410-b5e6-96231b3b80d8
Summary: This change gives Emscripten the ability to use more than one constructor priorities that runs before ASan. By convention, constructor priorites 0-100 are reserved for use by the system. ASan on Emscripten now uses priority 50, leaving plenty of room for use by Emscripten before and after ASan. This change is done in response to: emscripten-core/emscripten#9076 (comment) Reviewers: kripken, tlively, aheejin Reviewed By: tlively Subscribers: cfe-commits, dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D65684 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368101 91177308-0d34-0410-b5e6-96231b3b80d8
Based on #9073.