[compiler-rt] r177728 - [msan] Handle dlopen() failure in dlopen interceptor.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Fri Mar 22 04:59:49 PDT 2013
Author: eugenis
Date: Fri Mar 22 06:59:49 2013
New Revision: 177728
URL: http://llvm.org/viewvc/llvm-project?rev=177728&view=rev
Log:
[msan] Handle dlopen() failure in dlopen interceptor.
Modified:
compiler-rt/trunk/lib/msan/msan_interceptors.cc
compiler-rt/trunk/lib/msan/tests/msan_test.cc
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=177728&r1=177727&r2=177728&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Fri Mar 22 06:59:49 2013
@@ -807,7 +807,7 @@ INTERCEPTOR(void *, dlopen, const char *
EnterLoader();
link_map *map = (link_map *)REAL(dlopen)(filename, flag);
ExitLoader();
- if (!__msan_has_dynamic_component()) {
+ if (!__msan_has_dynamic_component() && map) {
// If msandr didn't clear the shadow before the initializers ran, we do it
// ourselves afterwards.
UnpoisonMappedDSO(map);
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=177728&r1=177727&r2=177728&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Fri Mar 22 06:59:49 2013
@@ -1397,6 +1397,13 @@ TEST(MemorySanitizer, dlopen) {
delete[] path;
}
+
+// Regression test for a crash in dlopen() interceptor.
+TEST(MemorySanitizer, dlopenFailed) {
+ const char *path = "/libmsan_loadable_does_not_exist.x86_64.so";
+ void *lib = dlopen(path, RTLD_LAZY);
+ ASSERT_EQ(0, lib);
+}
} // namespace
TEST(MemorySanitizer, scanf) {
More information about the llvm-commits
mailing list