This is an archive of the discontinued LLVM Phabricator instance.

Support pthread_key_create symbol alias in MSan/NetBSD
ClosedPublic

Authored by krytarowski on Dec 2 2017, 5:39 AM.

Details

Summary

NetBSD uses indirection symbol for a set of threading functions.

Add alias to handle __libc_thr_keycreate the same way as pthread_key_create.

Sponsored by <The NetBSD Foundation>

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.Dec 2 2017, 5:39 AM

While there.. is lib/sanitizer_common/sanitizer_common_syscalls.inc required for MSan?

vitalybuka added inline comments.Dec 5 2017, 4:34 PM
lib/msan/msan_interceptors.cc
1530

NetBSD header contains following:
#define pthread_key_create __libc_thr_keycreate

Should you instead pthread_key_create interceptor define __libc_thr_keycreate?

krytarowski added inline comments.Dec 5 2017, 4:45 PM
lib/msan/msan_interceptors.cc
1530

pthread_key_create(3) can be called internally in libpthread() or some other way without symbol mangling, this is why I want to intercept both symbol names.

This was the case in TSan in functions like pthread_mutex_lock(3).

Long term NetBSD will likely drop the symbol indirection and remove names like __libc_thr_keycreate.

vitalybuka accepted this revision.Dec 5 2017, 4:59 PM
vitalybuka added inline comments.
lib/msan/msan_interceptors.cc
1656

could you please move this and interceptor itself next to corresponding pthread_key_create lines

This revision is now accepted and ready to land.Dec 5 2017, 4:59 PM
krytarowski closed this revision.Dec 5 2017, 5:17 PM

Just reminding about my side question:

While there.. is lib/sanitizer_common/sanitizer_common_syscalls.inc required for MSan?

I will try to port it to NetBSD and see whether it helps MSan to work better.