From 214e64135ee22e8aa7f71e56e0f5662dc6746ad0 Mon Sep 17 00:00:00 2001 From: Dmitriy Ivanov Date: Fri, 30 May 2014 18:03:26 -0700 Subject: [PATCH] Make atexit.dlclose work for glibc * build libtest_atexit.so * remove atexit(NULL) - glibc segfaults on it Bug: 15350494 Change-Id: I27d79130c32c5691b0e8790a57d92f9710f5bf4a --- tests/Android.mk | 4 +++- tests/atexit_test.cpp | 4 ---- tests/atexit_testlib.cpp | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/Android.mk b/tests/Android.mk index b75964a05..db8dd8cc7 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -312,8 +312,10 @@ libtest_atexit_src_files := \ atexit_testlib.cpp module := libtest_atexit -build_type := target build_target := SHARED_LIBRARY +build_type := target +include $(LOCAL_PATH)/Android.build.mk +build_type := host include $(LOCAL_PATH)/Android.build.mk # ----------------------------------------------------------------------------- diff --git a/tests/atexit_test.cpp b/tests/atexit_test.cpp index 797231f1b..e01220e1b 100644 --- a/tests/atexit_test.cpp +++ b/tests/atexit_test.cpp @@ -25,7 +25,6 @@ #include TEST(atexit, dlclose) { -#if defined(__BIONIC__) std::string atexit_call_sequence; bool valid_this_in_static_dtor = false; void* handle = dlopen("libtest_atexit.so", RTLD_NOW); @@ -39,9 +38,6 @@ TEST(atexit, dlclose) { // this test verifies atexit call from atexit handler. as well as the order of calls ASSERT_EQ("Humpty Dumpty sat on a wall", atexit_call_sequence); ASSERT_TRUE(valid_this_in_static_dtor); -#else // __BIONIC__ - GTEST_LOG_(INFO) << "This test does nothing."; -#endif // __BIONIC__ } class TestMainStaticDtorClass { diff --git a/tests/atexit_testlib.cpp b/tests/atexit_testlib.cpp index 1fefdf00c..d35f57b74 100644 --- a/tests/atexit_testlib.cpp +++ b/tests/atexit_testlib.cpp @@ -71,6 +71,5 @@ extern "C" void register_atexit(std::string* sequence, bool* valid_this_in_stati atexit_valid_this_in_static_dtor = valid_this_in_static_dtor; atexit(atexit_handler_regular); atexit(atexit_handler_with_atexit); - atexit(NULL); }