From 0289253d4fb664a6b99d2467dcfb08a17f75931b Mon Sep 17 00:00:00 2001 From: Bob131 Date: Mon, 14 Jun 2021 06:07:48 +1000 Subject: [PATCH 1/3] test/64bit_child: search for librrpreload The test binary for 64bit_child determines the bitness of the process by searching the memory map for either 'librrpage.so' or 'librrpage_32.so'. This commit makes the test independent of the SONAME of librrpage by instead searching for librrpreload. --- src/test/64bit_child.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/64bit_child.c b/src/test/64bit_child.c index 4c44a98b597..1eb6d462df6 100644 --- a/src/test/64bit_child.c +++ b/src/test/64bit_child.c @@ -3,7 +3,7 @@ #include "util.h" void callback(uint64_t env, char *name, __attribute__((unused)) map_properties_t* props) { - const char search[] = "librrpage.so"; + const char search[] = "librrpreload.so"; if (strlen(name) > strlen(search)) { if (sizeof(void*) == 4 && strcmp(name + strlen(name) - strlen(search), search) == 0) From e6d11d9837caaad68f38c518ef1ec3fb692b0610 Mon Sep 17 00:00:00 2001 From: Bob131 Date: Fri, 11 Jun 2021 12:13:35 +1000 Subject: [PATCH 2/3] rrpage: use Linux vDSO soname AddressSanitizer complains if it isn't the first shared object in the link map besides the vDSO. It checks for the vDSO by testing whether the DT_SONAME of the object starts with 'linux-'. With the introduction of librrpage, this check no longer passes and causes ASan-instrumented programs to abort when being recorded by rr. This patch alters the linker arguments used for producing the librrpage dummy vDSO such that its SONAME is 'linux-vdso.so.1'. --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cd1d80cd96..837c1529cc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,7 +342,12 @@ foreach(file ${RR_PAGE_FILES}) set_source_files_properties("${CMAKE_SOURCE_DIR}/src/preload/${file}" PROPERTIES COMPILE_FLAGS ${PRELOAD_COMPILE_FLAGS}) endforeach(file) -set_target_properties(rrpage PROPERTIES LINK_FLAGS "-Wl,-T -Wl,${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld -Wl,--hash-style=both -nostartfiles -nostdlib -Wl,-z,max-page-size=0x1000 ${LINKER_FLAGS}") + +# Since librrpage replaces the kernel vDSO for processes exec'd by rr, +# we want it to have the same SONAME as the real vDSO to trick things +# like AddressSanitizer into recognising it as the vDSO. +set_target_properties(rrpage PROPERTIES NO_SONAME ON) +set_target_properties(rrpage PROPERTIES LINK_FLAGS "-Wl,-T -Wl,${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld -Wl,--hash-style=both -nostartfiles -nostdlib -Wl,-z,max-page-size=0x1000 -Wl,-soname,linux-vdso.so.1 ${LINKER_FLAGS}") set_target_properties(rrpage PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld) # CMake seems to have trouble generating the link line without this set_target_properties(rrpage PROPERTIES LINKER_LANGUAGE C) @@ -672,7 +677,8 @@ if(rr_32BIT AND rr_64BIT) PROPERTIES COMPILE_FLAGS "-m32 ${PRELOAD_COMPILE_FLAGS}") endforeach(file) - set_target_properties(rrpage_32 PROPERTIES LINK_FLAGS "-m32 -Wl,-T -Wl,${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld -Wl,--hash-style=both -nostartfiles -nostdlib ${LINKER_FLAGS}") + set_target_properties(rrpage_32 PROPERTIES NO_SONAME ON) + set_target_properties(rrpage_32 PROPERTIES LINK_FLAGS "-m32 -Wl,-T -Wl,${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld -Wl,--hash-style=both -nostartfiles -nostdlib -Wl,-soname,linux-vdso.so.1 ${LINKER_FLAGS}") set_target_properties(rrpage_32 PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/src/preload/rr_page.ld) set_target_properties(rrpage_32 PROPERTIES LINKER_LANGUAGE C) From c41472e4b6cbf6f810e355cd516cca00b5170d89 Mon Sep 17 00:00:00 2001 From: Bob131 Date: Fri, 11 Jun 2021 12:47:23 +1000 Subject: [PATCH 3/3] build: make test timeout configurable The CMake test property TIMEOUT has higher priority than the user-supplied --timeout switch. The exceptionally long default setting (1000 seconds) can make tests that aren't entirely controlled by test-monitor very painful to run. This commit instead sets CTEST_TEST_TIMEOUT, allowing the user to override the timeout at test run time. --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 837c1529cc1..350f397fd1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1566,10 +1566,11 @@ if(BUILD_TESTS) set(TEST_MONITOR_DEFAULT_TIMEOUT 120) endif() + # The real timeouts are handled by test-monitor + set(CTEST_TEST_TIMEOUT 1000) + function(configure_test test) - # The real timeouts are handled by test-monitor - set_tests_properties(${test} - PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED" TIMEOUT 1000) + set_tests_properties(${test} PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED") endfunction(configure_test) if(INSTALL_TESTSUITE)