This is an archive of the discontinued LLVM Phabricator instance.

[lsan] Handle fork() correctly.
ClosedPublic

Authored by earthdok on Jul 5 2013, 9:45 AM.

Details

Summary

Update the main thread's os_id on every pthread_create, and before
initiating leak checking. This ensures that we have the correct os_id even if we
have forked after Init(). Not sure of the performance implications for
pthread_create, but this is more robust than intercepting fork() since this
scheme handles fork by syscall too.

Diff Detail

Event Timeline

Can you please clarify why we it is necessary to ensure correct os_id before pthread_create?

lib/asan/asan_interceptors.cc
141

Please add this to CreateThread() interceptor as well.

lib/asan/asan_thread.cc
259

static_cast here for consistency.

lib/asan/asan_thread.h
127

I think the comment needs to be more explicit.

earthdok accepted this revision.Jul 8 2013, 5:56 AM
earthdok added inline comments.
lib/asan/asan_interceptors.cc
141

As discussed offline, this is not needed since fork() without exec() does not have a Windows equivalent.

lib/asan/asan_thread.cc
259

Actually this needs a reinterpret_cast. Also fixed in GetCurrentThread().

lib/asan/asan_thread.h
127

fixed

earthdok closed this revision.Dec 5 2014, 9:41 AM