Skip to content

Commit 9c76589

Browse files
committed
druntime/dmain2: disable RTSan monitoring in init_rt ...
... this function is not real-time safe and also not rtsan safe (will lock-up rtsan's stack scanner)
1 parent 120e752 commit 9c76589

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

runtime/druntime/src/rt/dmain2.d

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ extern (C) void thread_joinAll();
7070
extern (C) UnitTestResult runModuleUnitTests();
7171
extern (C) void _d_initMonoTime() @nogc nothrow;
7272

73+
version (SupportSanitizers)
74+
{
75+
import ldc.attributes;
76+
77+
@weak extern (C) void __rtsan_disable() @nogc nothrow {}
78+
@weak extern (C) void __rtsan_enable() @nogc nothrow {}
79+
@weak extern (C) void __rtsan_notify_blocking_call(const char* name) @nogc nothrow {}
80+
}
81+
7382
version (CRuntime_Microsoft)
7483
{
7584
extern(C) void init_msvc();
@@ -103,6 +112,12 @@ private shared size_t _initCount;
103112
*/
104113
extern (C) int rt_init()
105114
{
115+
version (SupportSanitizers)
116+
{
117+
__rtsan_notify_blocking_call("rt_init");
118+
__rtsan_disable();
119+
scope (exit) __rtsan_enable();
120+
}
106121
/* @@BUG 11380 @@ Need to synchronize rt_init/rt_term calls for
107122
version (Shared) druntime, because multiple C threads might
108123
initialize different D libraries without knowing about the

0 commit comments

Comments
 (0)