Skip to content

[TSan] Support initialize/finalize hooks in dynamic libraries #2745

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 1 commit into from
Mar 25, 2021

Conversation

yln
Copy link

@yln yln commented Mar 24, 2021

Make TSan runtime initialization and finalization hooks work
even if these hooks are not built in the main executable. When these
hooks are defined in another library that is not directly linked against
the TSan runtime (e.g., Swift runtime) we cannot rely on the "strong-def
overriding weak-def" mechanics and have to look them up via dlsym().

Let's also define hooks that are easier to use from C-only code:

extern "C" void __tsan_on_initialize();
extern "C" int __tsan_on_finalize(int failed);

For now, these will call through to the old hooks. Eventually, we want
to adopt the new hooks downstream and remove the old ones.

This is part of the effort to support Swift Tasks (async/await and
actors) in TSan.

rdar://74256720

Reviewed By: vitalybuka, delcypher

Differential Revision: https://reviews.llvm.org/D98810

(cherry picked from commit 26e0fb8)

Make TSan runtime initialization and finalization hooks work
even if these hooks are not built in the main executable.  When these
hooks are defined in another library that is not directly linked against
the TSan runtime (e.g., Swift runtime) we cannot rely on the "strong-def
overriding weak-def" mechanics and have to look them up via `dlsym()`.

Let's also define hooks that are easier to use from C-only code:
```
extern "C" void __tsan_on_initialize();
extern "C" int __tsan_on_finalize(int failed);
```
For now, these will call through to the old hooks.  Eventually, we want
to adopt the new hooks downstream and remove the old ones.

This is part of the effort to support Swift Tasks (async/await and
actors) in TSan.

rdar://74256720

Reviewed By: vitalybuka, delcypher

Differential Revision: https://reviews.llvm.org/D98810

(cherry picked from commit 26e0fb8)
@yln yln self-assigned this Mar 24, 2021
@yln
Copy link
Author

yln commented Mar 24, 2021

Cherry-picking open source change to enable: swiftlang/swift#36478

This is a change confined to the TSan runtime, so we can skip CCC.

@yln
Copy link
Author

yln commented Mar 24, 2021

@swift-ci Please test

@yln
Copy link
Author

yln commented Mar 24, 2021

Linux fails with an unrelated error:

17:32:35   File "/home/buildnode/jenkins/workspace/apple-llvm-project-pr-linux/llvm-project/build/bin/../../llvm/utils/lit/lit/cl_arguments.py", line 12, in TestOrder
17:32:35     DEFAULT = enum.auto()
17:32:35 AttributeError: module 'enum' has no attribute 'auto'
17:32:35 FAILED: CMakeFiles/check-all 

@shahmishal
Are we using Python >= 3.6 on the Linux bots?
https://docs.python.org/3/library/enum.html#enum.auto

@yln yln merged commit c64f3e6 into apple/stable/20210107 Mar 25, 2021
@yln yln deleted the cherry-pick-tsan-on-init branch March 25, 2021 00:06
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.

1 participant