Previously AtosSymbolizer would set the PID to examine in the
constructor which is called early on during sanitizer init. This can
lead to incorrect behaviour in the case of a fork() because if the
symbolizer is launched in the child it will be told examine the parent
process rather than the child.
To fix this the PID is determined just before the symbolizer is
launched.
A test case is included that triggers the buggy behaviour that existed
prior to this patch. The test observes the PID that atos was called
on. It also examines the symbolized stacktrace. Prior to this patch
atos failed to symbolize the stacktrace giving output that looked
like...
#0 0x100fc3bb5 in __sanitizer_print_stack_trace asan_stack.cpp:86 #1 0x10490dd36 in PrintStack+0x56 (/path/to/print-stack-trace-in-code-loaded-after-fork.cpp.tmp_shared_lib:x86_64+0xd36) #2 0x100f6f986 in main+0x4a6 (path/to/print-stack-trace-in-code-loaded-after-fork.cpp.tmp_loader:x86_64+0x100001986) #3 0x7fff714f1cc8 in start+0x0 (/usr/lib/system/libdyld.dylib:x86_64+0x1acc8)
After this patch stackframes #1 and #2 are fully symbolized.
This patch is also a pre-requisite refactor for rdar://problem/58789439.
Can you explain why the separately loaded lib/dlopen is required to trigger the error condition? From the commit message I thought that a fork should be enough? Other than that: LGTM