Files
Tony Printezis e36a0fa5bc Fix prof-sampling / guard-page interaction bug in the SAN
Due to an incorrect condition, a prof-promoted small allocation
was incorrectly wrapped in large-extent guard pages. This consumed
the large-guard budget, so the next genuinely large allocation that
should have been guarded got skipped.
2026-08-10 09:16:09 -04:00

30 lines
883 B
C

#include "test/jemalloc_test.h"
#include "test/san.h"
#include "jemalloc/internal/prof_inlines.h"
TEST_BEGIN(test_prof_sampled_small_is_not_guarded_as_large) {
test_skip_if(!config_prof);
tsd_t *tsd = tsd_fetch();
void *small = malloc(PAGE / 2);
expect_ptr_not_null(small, "Unexpected small allocation failure");
expect_true(prof_sampled(tsd, small),
"Expected every allocation to be prof sampled");
expect_false(extent_is_guarded(tsd_tsdn(tsd), small),
"A prof-promoted small allocation is not a large extent");
free(small);
void *large = malloc(SC_LARGE_MINCLASS);
expect_ptr_not_null(large, "Unexpected large allocation failure");
expect_true(extent_is_guarded(tsd_tsdn(tsd), large),
"The next eligible large extent should still be guarded");
free(large);
}
TEST_END
int
main(void) {
return test(test_prof_sampled_small_is_not_guarded_as_large);
}