-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
[NFC][asan] Switch to IntrusiveList in asan_globals #101577
Merged
vitalybuka
merged 6 commits into
main
from
users/vitalybuka/spr/nfcasan-switch-to-intrusivelist-in-asan_globals
Aug 2, 2024
Merged
[NFC][asan] Switch to IntrusiveList in asan_globals #101577
vitalybuka
merged 6 commits into
main
from
users/vitalybuka/spr/nfcasan-switch-to-intrusivelist-in-asan_globals
Aug 2, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
llvmbot
added
compiler-rt
compiler-rt:asan
Address sanitizer
compiler-rt:sanitizer
labels
Aug 1, 2024
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) ChangesIt's preparation for switching to hash table. Full diff: https://github.com/llvm/llvm-project/pull/101577.diff 1 Files Affected:
diff --git a/compiler-rt/lib/asan/asan_globals.cpp b/compiler-rt/lib/asan/asan_globals.cpp
index 9766488fed0c9..90481467d5eb8 100644
--- a/compiler-rt/lib/asan/asan_globals.cpp
+++ b/compiler-rt/lib/asan/asan_globals.cpp
@@ -45,15 +45,13 @@ static ListOfGlobals list_of_all_globals SANITIZER_GUARDED_BY(mu_for_globals);
static MapOfGlobals map_of_globals_by_indicator
SANITIZER_GUARDED_BY(mu_for_globals);
-static const int kDynamicInitGlobalsInitialCapacity = 512;
struct DynInitGlobal {
- Global g;
- bool initialized;
+ Global g = {};
+ bool initialized = false;
+ DynInitGlobal *next = nullptr;
};
-typedef InternalMmapVector<DynInitGlobal> VectorOfGlobals;
-// Lazy-initialized and never deleted.
-static VectorOfGlobals *dynamic_init_globals
- SANITIZER_GUARDED_BY(mu_for_globals);
+typedef IntrusiveList<DynInitGlobal> DynInitGlobals;
+static DynInitGlobals dynamic_init_globals SANITIZER_GUARDED_BY(mu_for_globals);
// We want to remember where a certain range of globals was registered.
struct GlobalRegistrationSite {
@@ -249,12 +247,8 @@ static void RegisterGlobal(const Global *g) SANITIZER_REQUIRES(mu_for_globals) {
AddGlobalToList(list_of_all_globals, g);
if (g->has_dynamic_init) {
- if (!dynamic_init_globals) {
- dynamic_init_globals = new (GetGlobalLowLevelAllocator()) VectorOfGlobals;
- dynamic_init_globals->reserve(kDynamicInitGlobalsInitialCapacity);
- }
- DynInitGlobal dyn_global = { *g, false };
- dynamic_init_globals->push_back(dyn_global);
+ dynamic_init_globals.push_back(new (GetGlobalLowLevelAllocator())
+ DynInitGlobal{*g, false});
}
}
@@ -284,11 +278,8 @@ void StopInitOrderChecking() {
if (!flags()->check_initialization_order)
return;
Lock lock(&mu_for_globals);
- if (!dynamic_init_globals)
- return;
flags()->check_initialization_order = false;
- for (uptr i = 0, n = dynamic_init_globals->size(); i < n; ++i) {
- DynInitGlobal &dyn_g = (*dynamic_init_globals)[i];
+ for (const DynInitGlobal &dyn_g : dynamic_init_globals) {
const Global *g = &dyn_g.g;
// Unpoison the whole global.
PoisonShadowForGlobal(g, 0);
@@ -455,12 +446,9 @@ void __asan_before_dynamic_init(const char *module_name) {
CHECK(module_name);
CHECK(AsanInited());
Lock lock(&mu_for_globals);
- if (!dynamic_init_globals)
- return;
if (flags()->report_globals >= 3)
Printf("DynInitPoison module: %s\n", module_name);
- for (uptr i = 0, n = dynamic_init_globals->size(); i < n; ++i) {
- DynInitGlobal &dyn_g = (*dynamic_init_globals)[i];
+ for (DynInitGlobal &dyn_g : dynamic_init_globals) {
const Global *g = &dyn_g.g;
if (dyn_g.initialized)
continue;
@@ -479,11 +467,8 @@ void __asan_after_dynamic_init() {
return;
CHECK(AsanInited());
Lock lock(&mu_for_globals);
- if (!dynamic_init_globals)
- return;
// FIXME: Optionally report that we're unpoisoning globals from a module.
- for (uptr i = 0, n = dynamic_init_globals->size(); i < n; ++i) {
- DynInitGlobal &dyn_g = (*dynamic_init_globals)[i];
+ for (const DynInitGlobal &dyn_g : dynamic_init_globals) {
const Global *g = &dyn_g.g;
if (!dyn_g.initialized) {
// Unpoison the whole global.
|
Created using spr 1.3.4 [skip ci]
kstoimenov
approved these changes
Aug 2, 2024
Created using spr 1.3.4 [skip ci]
vitalybuka
changed the base branch from
users/vitalybuka/spr/main.nfcasan-switch-to-intrusivelist-in-asan_globals
to
main
August 2, 2024 06:40
vitalybuka
deleted the
users/vitalybuka/spr/nfcasan-switch-to-intrusivelist-in-asan_globals
branch
August 2, 2024 06:42
banach-space
pushed a commit
to banach-space/llvm-project
that referenced
this pull request
Aug 7, 2024
It's preparation for switching to hash table in llvm#101596.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's preparation for switching to hash table in #101596.