Skip to content

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

Merged
merged 15 commits into from
Aug 7, 2019
Merged

Conversation

quantum5
Copy link
Member

@quantum5 quantum5 commented Jul 25, 2019

Based on #9073.

Copy link
Member

@tlively tlively left a 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'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lsan->asan?

Copy link
Member Author

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)))
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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

llvm-git-migration pushed a commit to llvm/llvm-project that referenced this pull request Aug 6, 2019
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
dtzWill pushed a commit to llvm-mirror/clang that referenced this pull request Aug 6, 2019
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
dtzWill pushed a commit to llvm-mirror/llvm that referenced this pull request Aug 6, 2019
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
spurious pushed a commit to spurious/clang-mirror that referenced this pull request Aug 6, 2019
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
@quantum5 quantum5 merged commit fdd6069 into emscripten-core:incoming Aug 7, 2019
earl pushed a commit to earl/llvm-mirror that referenced this pull request Aug 17, 2019
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
belraquib pushed a commit to belraquib/emscripten that referenced this pull request Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants