Closed GoogleCodeExporter closed 9 years ago
LLVM revision r179843 should fix this testcase. It changes the default
init-order checker mode to the one that _accepts_ access to already initialized
globals. Note, that this change is required for, e.g. testing LLVM itself: when
a certain global is initialized, it adds itself to a global registry, assuming
it can be safely accessed during the following initialization. I've seen at
least one other project that uses the same pattern.
Still, we may lose a lot of potential bugs in this way :(
My suggestion is to use "strict-init-order" flag for codebases that are known
to not use such machinery, and fight with described dlopen() issue by some of:
1) intercept pthread_create() and/or dlopen() and stop init-order checking when
they are called.
2) add an interface function __asan_stop_init_order_checking(). It can be
called at the beginning of main().
3) use nifty hacks: if we've dlopened() a .so, find out where its globals are
located, and poison only them during module initialization (ew-w-w).
Original comment by samso...@google.com
on 19 Apr 2013 at 8:56
#1.a is probably the simplest (stop once we have more than 1 thread). Although
I can imagine a situation where a thread is started from a module initializer.
Grrr.
Original comment by konstant...@gmail.com
on 19 Apr 2013 at 2:08
I've implemented #1.a in LLVM r180106.
Original comment by samso...@google.com
on 23 Apr 2013 at 1:59
can we close this?
Original comment by konstant...@gmail.com
on 29 Jan 2014 at 1:24
Original comment by samso...@google.com
on 29 Jan 2014 at 2:54
FTR the problem description provided here is a bit misleading. strict
init-order checker is *both* multithreading- and dlopen()-hostile: we can end
up with false positives both if use dlopen() in a single-threaded program, and
if we call spawn new threads during initialization, but don't call dlopen().
That is, we need to disable init-order checker both in pthread_create
interceptor (was done in r180106) and in dlopen interceptor (this is addressed
in r230288).
Original comment by samso...@google.com
on 24 Feb 2015 at 12:41
Original issue reported on code.google.com by
samso...@google.com
on 15 Apr 2013 at 12:49