Remove safety check abort mallctl

This commit is contained in:
Slobodan Predolac 2026-05-22 10:08:45 -07:00
parent bbe86b591f
commit 9cecc7bfa7
12 changed files with 33 additions and 64 deletions

View file

@ -12,14 +12,14 @@ fake_abort(const char *message) {
static void
test_double_free_pre(void) {
safety_check_set_abort(&fake_abort);
test_hooks_safety_check_abort = &fake_abort;
fake_abort_called = false;
}
static void
test_double_free_post(void) {
expect_b_eq(fake_abort_called, true, "Double-free check didn't fire.");
safety_check_set_abort(NULL);
test_hooks_safety_check_abort = NULL;
}
static bool

View file

@ -25,12 +25,12 @@ TEST_BEGIN(test_malloc_free_overflow) {
test_skip_if(!config_prof);
test_skip_if(!config_opt_safety_checks);
safety_check_set_abort(&fake_abort);
test_hooks_safety_check_abort = &fake_abort;
/* Buffer overflow! */
char *ptr = malloc(128);
buffer_overflow_write(ptr, 128);
free(ptr);
safety_check_set_abort(NULL);
test_hooks_safety_check_abort = NULL;
expect_b_eq(fake_abort_called, true, "Redzone check didn't fire.");
fake_abort_called = false;
@ -41,12 +41,12 @@ TEST_BEGIN(test_mallocx_dallocx_overflow) {
test_skip_if(!config_prof);
test_skip_if(!config_opt_safety_checks);
safety_check_set_abort(&fake_abort);
test_hooks_safety_check_abort = &fake_abort;
/* Buffer overflow! */
char *ptr = mallocx(128, 0);
buffer_overflow_write(ptr, 128);
dallocx(ptr, 0);
safety_check_set_abort(NULL);
test_hooks_safety_check_abort = NULL;
expect_b_eq(fake_abort_called, true, "Redzone check didn't fire.");
fake_abort_called = false;
@ -57,12 +57,12 @@ TEST_BEGIN(test_malloc_sdallocx_overflow) {
test_skip_if(!config_prof);
test_skip_if(!config_opt_safety_checks);
safety_check_set_abort(&fake_abort);
test_hooks_safety_check_abort = &fake_abort;
/* Buffer overflow! */
char *ptr = malloc(128);
buffer_overflow_write(ptr, 128);
sdallocx(ptr, 128, 0);
safety_check_set_abort(NULL);
test_hooks_safety_check_abort = NULL;
expect_b_eq(fake_abort_called, true, "Redzone check didn't fire.");
fake_abort_called = false;
@ -73,12 +73,12 @@ TEST_BEGIN(test_realloc_overflow) {
test_skip_if(!config_prof);
test_skip_if(!config_opt_safety_checks);
safety_check_set_abort(&fake_abort);
test_hooks_safety_check_abort = &fake_abort;
/* Buffer overflow! */
char *ptr = malloc(128);
buffer_overflow_write(ptr, 128);
ptr = realloc(ptr, 129);
safety_check_set_abort(NULL);
test_hooks_safety_check_abort = NULL;
free(ptr);
expect_b_eq(fake_abort_called, true, "Redzone check didn't fire.");
@ -90,12 +90,12 @@ TEST_BEGIN(test_rallocx_overflow) {
test_skip_if(!config_prof);
test_skip_if(!config_opt_safety_checks);
safety_check_set_abort(&fake_abort);
test_hooks_safety_check_abort = &fake_abort;
/* Buffer overflow! */
char *ptr = malloc(128);
buffer_overflow_write(ptr, 128);
ptr = rallocx(ptr, 129, 0);
safety_check_set_abort(NULL);
test_hooks_safety_check_abort = NULL;
free(ptr);
expect_b_eq(fake_abort_called, true, "Redzone check didn't fire.");
@ -107,7 +107,7 @@ TEST_BEGIN(test_xallocx_overflow) {
test_skip_if(!config_prof);
test_skip_if(!config_opt_safety_checks);
safety_check_set_abort(&fake_abort);
test_hooks_safety_check_abort = &fake_abort;
/* Buffer overflow! */
char *ptr = malloc(128);
buffer_overflow_write(ptr, 128);
@ -116,7 +116,7 @@ TEST_BEGIN(test_xallocx_overflow) {
free(ptr);
expect_b_eq(fake_abort_called, true, "Redzone check didn't fire.");
fake_abort_called = false;
safety_check_set_abort(NULL);
test_hooks_safety_check_abort = NULL;
}
TEST_END

View file

@ -17,7 +17,7 @@ fake_abort(const char *message) {
static void *
test_invalid_size_pre(size_t sz) {
safety_check_set_abort(&fake_abort);
test_hooks_safety_check_abort = &fake_abort;
fake_abort_called = false;
void *ptr = malloc(sz);
@ -29,7 +29,7 @@ test_invalid_size_pre(size_t sz) {
static void
test_invalid_size_post(void) {
expect_true(fake_abort_called, "Safety check didn't fire");
safety_check_set_abort(NULL);
test_hooks_safety_check_abort = NULL;
}
TEST_BEGIN(test_invalid_size_sdallocx) {

View file

@ -19,7 +19,7 @@ fake_abort(const char *message) {
static void
test_write_after_free_pre(void) {
safety_check_set_abort(&fake_abort);
test_hooks_safety_check_abort = &fake_abort;
fake_abort_called = false;
}
@ -28,7 +28,7 @@ test_write_after_free_post(void) {
assert_d_eq(mallctl("thread.tcache.flush", NULL, NULL, NULL, 0), 0,
"Unexpected tcache flush failure");
expect_true(fake_abort_called, "Use-after-free check didn't fire.");
safety_check_set_abort(NULL);
test_hooks_safety_check_abort = NULL;
}
static bool

View file

@ -12,7 +12,7 @@ set_abort_called(const char *message) {
TEST_BEGIN(test_realloc_abort) {
abort_called = false;
safety_check_set_abort(&set_abort_called);
test_hooks_safety_check_abort = &set_abort_called;
void *ptr = mallocx(42, 0);
expect_ptr_not_null(ptr, "Unexpected mallocx error");
ptr = realloc(ptr, 0);