Skip to content

Commit

Permalink
#Centipede Resolve an initialization order fiasco error.
Browse files Browse the repository at this point in the history
Accessing X_orig before initialization is supported and should not be consider as an error here.

PiperOrigin-RevId: 648738001
  • Loading branch information
xinhaoyuan authored and copybara-github committed Jul 2, 2024
1 parent aadda56 commit 6418ec2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions centipede/runner_interceptors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,18 @@ void RunnerInterceptor() {} // to be referenced in runner.cc
#define SANITIZER_INTERCEPTOR_NAME(orig_func_name) \
__interceptor_##orig_func_name
#define DECLARE_CENTIPEDE_ORIG_FUNC(ret_type, orig_func_name, args) \
extern "C" __attribute__((weak)) \
ret_type(SANITIZER_INTERCEPTOR_NAME(orig_func_name)) args; \
extern "C" __attribute__((weak)) ret_type( \
SANITIZER_INTERCEPTOR_NAME(orig_func_name)) args; \
static decltype(&SANITIZER_INTERCEPTOR_NAME( \
orig_func_name)) GetOrig_##orig_func_name() { \
if (auto p = &SANITIZER_INTERCEPTOR_NAME(orig_func_name)) return p; \
return FuncAddr<decltype(&SANITIZER_INTERCEPTOR_NAME(orig_func_name))>( \
#orig_func_name); \
} \
static ret_type(*orig_func_name##_orig) args = GetOrig_##orig_func_name()
static ret_type(*orig_func_name##_orig) args; \
__attribute__((constructor)) void InitializeOrig_##orig_func_name() { \
orig_func_name##_orig = GetOrig_##orig_func_name(); \
}
#define REAL(orig_func_name) \
(orig_func_name##_orig ? orig_func_name##_orig : GetOrig_##orig_func_name())

Expand Down

0 comments on commit 6418ec2

Please sign in to comment.