-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "[Scudo] Make -fsanitize=scudo use standalone. Migrate tests."
This reverts commit 6911114. Broke the QEMU sanitizer bots due to a missing header dependency. This actually needs to be fixed on the bot-side, but for now reverting this patch until I can fix up the bot.
- Loading branch information
Showing
37 changed files
with
297 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
set(SCUDO_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
set(SCUDO_LIT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
set(SCUDO_TESTSUITES) | ||
|
||
set(SCUDO_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) | ||
if(NOT COMPILER_RT_STANDALONE_BUILD) | ||
list(APPEND SCUDO_TEST_DEPS scudo) | ||
endif() | ||
|
||
configure_lit_site_cfg( | ||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in | ||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py | ||
) | ||
|
||
set(SCUDO_TEST_ARCH ${SCUDO_SUPPORTED_ARCH}) | ||
foreach(arch ${SCUDO_TEST_ARCH}) | ||
set(SCUDO_TEST_TARGET_ARCH ${arch}) | ||
string(TOLOWER "-${arch}" SCUDO_TEST_CONFIG_SUFFIX) | ||
get_test_cc_for_arch(${arch} SCUDO_TEST_TARGET_CC SCUDO_TEST_TARGET_CFLAGS) | ||
string(TOUPPER ${arch} ARCH_UPPER_CASE) | ||
set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) | ||
|
||
configure_lit_site_cfg( | ||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in | ||
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) | ||
list(APPEND SCUDO_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) | ||
endforeach() | ||
|
||
add_subdirectory(standalone) | ||
|
||
add_lit_testsuite(check-scudo "Running the Scudo Hardened Allocator tests" | ||
${SCUDO_TESTSUITES} | ||
DEPENDS ${SCUDO_TEST_DEPS}) | ||
set_target_properties(check-scudo PROPERTIES FOLDER "Compiler-RT Misc") |
6 changes: 3 additions & 3 deletions
6
...-rt/test/scudo/standalone/aligned-new.cpp → compiler-rt/test/scudo/aligned-new.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...iler-rt/test/scudo/standalone/alignment.c → compiler-rt/test/scudo/alignment.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
...r-rt/test/scudo/standalone/dealloc-race.c → compiler-rt/test/scudo/dealloc-race.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...-rt/test/scudo/standalone/double-free.cpp → compiler-rt/test/scudo/double-free.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
...iler-rt/test/scudo/standalone/fsanitize.c → compiler-rt/test/scudo/fsanitize.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// RUN: %clangxx_scudo %s -lstdc++ -o %t | ||
// RUN: %run %t ownership 2>&1 | ||
// RUN: %run %t ownership-and-size 2>&1 | ||
// RUN: %run %t heap-size 2>&1 | ||
// RUN: %env_scudo_opts="allocator_may_return_null=1" %run %t soft-limit 2>&1 | ||
// RUN: %env_scudo_opts="allocator_may_return_null=1" not %run %t hard-limit 2>&1 | ||
|
||
// Tests that the sanitizer interface functions behave appropriately. | ||
|
||
#include <assert.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
#include <vector> | ||
|
||
#include <sanitizer/allocator_interface.h> | ||
#include <sanitizer/scudo_interface.h> | ||
|
||
int main(int argc, char **argv) { | ||
assert(argc == 2); | ||
|
||
if (!strcmp(argv[1], "ownership")) { | ||
// Ensures that __sanitizer_get_ownership can be called before any other | ||
// allocator function, and that it behaves properly on a pointer not owned | ||
// by us. | ||
assert(!__sanitizer_get_ownership(argv)); | ||
} | ||
if (!strcmp(argv[1], "ownership-and-size")) { | ||
// Tests that __sanitizer_get_ownership and __sanitizer_get_allocated_size | ||
// behave properly on chunks allocated by the Primary and Secondary. | ||
void *p; | ||
std::vector<ssize_t> sizes{1, 8, 16, 32, 1024, 32768, | ||
1 << 16, 1 << 17, 1 << 20, 1 << 24}; | ||
for (size_t size : sizes) { | ||
p = malloc(size); | ||
assert(p); | ||
assert(__sanitizer_get_ownership(p)); | ||
assert(__sanitizer_get_allocated_size(p) >= size); | ||
free(p); | ||
} | ||
} | ||
if (!strcmp(argv[1], "heap-size")) { | ||
// Ensures that __sanitizer_get_heap_size can be called before any other | ||
// allocator function. | ||
assert(__sanitizer_get_heap_size() >= 0); | ||
} | ||
if (!strcmp(argv[1], "soft-limit")) { | ||
// Verifies that setting the soft RSS limit at runtime works as expected. | ||
std::vector<void *> pointers; | ||
size_t size = 1 << 19; // 512Kb | ||
for (int i = 0; i < 5; i++) { | ||
void *p = malloc(size); | ||
memset(p, 0, size); | ||
pointers.push_back(p); | ||
} | ||
// Set the soft RSS limit to 1Mb. | ||
__scudo_set_rss_limit(1, 0); | ||
usleep(20000); | ||
// The following allocation should return NULL. | ||
void *p = malloc(size); | ||
assert(!p); | ||
// Remove the soft RSS limit. | ||
__scudo_set_rss_limit(0, 0); | ||
// The following allocation should succeed. | ||
p = malloc(size); | ||
assert(p); | ||
free(p); | ||
while (!pointers.empty()) { | ||
free(pointers.back()); | ||
pointers.pop_back(); | ||
} | ||
} | ||
if (!strcmp(argv[1], "hard-limit")) { | ||
// Verifies that setting the hard RSS limit at runtime works as expected. | ||
std::vector<void *> pointers; | ||
size_t size = 1 << 19; // 512Kb | ||
for (int i = 0; i < 5; i++) { | ||
void *p = malloc(size); | ||
memset(p, 0, size); | ||
pointers.push_back(p); | ||
} | ||
// Set the hard RSS limit to 1Mb | ||
__scudo_set_rss_limit(1, 1); | ||
usleep(20000); | ||
// The following should trigger our death. | ||
void *p = malloc(size); | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.