Skip to content

Commit

Permalink
Enable ubsan on more tests.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 706834439
Change-Id: Ib47f193c95f2945391e87bf1ac2b93df1ea05e0b
  • Loading branch information
ckennelly authored and copybara-github committed Dec 16, 2024
1 parent b7e0aa0 commit 49240b3
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 37 deletions.
7 changes: 6 additions & 1 deletion tcmalloc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,12 @@ cc_test(
copts = TCMALLOC_DEFAULT_COPTS,
linkstatic = 1,
malloc = "//tcmalloc:tcmalloc_deprecated_perthread",
tags = ["nosan"],
tags = [
"noasan",
"nomsan",
"notsan",
"noubsan",
],
deps = [
":malloc_extension",
"//tcmalloc/internal:logging",
Expand Down
5 changes: 4 additions & 1 deletion tcmalloc/sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ class Sampler {
friend class SamplerTest;
// Initialize this sampler.
void Init(uint64_t seed);
size_t RecordAllocationSlow(size_t k);

// TODO(b/148986845): Enable this to pass under ubsan for its signed overflow
// for extreme k and remove sanitizer opt-out.
size_t RecordAllocationSlow(size_t k) ABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED;
ssize_t GetGeometricVariable(ssize_t mean);
};

Expand Down
130 changes: 95 additions & 35 deletions tcmalloc/testing/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ create_tcmalloc_testsuite(
linkstatic = 1, # get the most realistic performance
shard_count = 3,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
visibility = ["//visibility:private"],
deps = [
Expand Down Expand Up @@ -119,7 +121,9 @@ cc_test(
copts = TCMALLOC_DEFAULT_COPTS,
malloc = "//tcmalloc:tcmalloc_deprecated_perthread",
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
"//tcmalloc:malloc_extension",
Expand All @@ -133,7 +137,9 @@ create_tcmalloc_testsuite(
srcs = ["memalign_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
"//tcmalloc/internal:page_size",
Expand All @@ -149,7 +155,9 @@ create_tcmalloc_testsuite(
srcs = ["frag_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
"//tcmalloc:malloc_extension",
Expand All @@ -164,7 +172,9 @@ create_tcmalloc_testsuite(
"$(STACK_FRAME_UNLIMITED)", # largesmall_frag_test.cc
] + TCMALLOC_DEFAULT_COPTS,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
":testutil",
Expand All @@ -191,7 +201,11 @@ cc_test(
srcs = ["outofmemory_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
malloc = "//tcmalloc",
tags = ["nosan"],
tags = [
"noasan",
"nomsan",
"notsan",
],
deps = [
":testutil",
"//tcmalloc:malloc_extension",
Expand Down Expand Up @@ -223,7 +237,9 @@ cc_test(
linkstatic = 1,
malloc = "//tcmalloc",
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
":testutil",
Expand All @@ -246,7 +262,9 @@ create_tcmalloc_testsuite(
srcs = ["sampling_memusage_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
"//tcmalloc:malloc_extension",
Expand Down Expand Up @@ -281,7 +299,11 @@ cc_test(
copts = TCMALLOC_DEFAULT_COPTS,
linkstatic = 1,
malloc = "//tcmalloc",
tags = ["nosan"],
tags = [
"noasan",
"nomsan",
"notsan",
],
deps = [
"//tcmalloc:malloc_extension",
"//tcmalloc/internal:logging",
Expand Down Expand Up @@ -327,7 +349,9 @@ create_tcmalloc_testsuite(
copts = TCMALLOC_DEFAULT_COPTS,
linkstatic = 1,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
":testutil",
Expand Down Expand Up @@ -364,7 +388,11 @@ create_tcmalloc_testsuite(
srcs = ["limit_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
linkstatic = 1,
tags = ["nosan"],
tags = [
"noasan",
"nomsan",
"notsan",
],
deps = [
":testutil",
"//tcmalloc:malloc_extension",
Expand All @@ -390,7 +418,9 @@ create_tcmalloc_testsuite(
}),
linkstatic = 1,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
"//tcmalloc:malloc_extension",
Expand All @@ -407,7 +437,11 @@ create_tcmalloc_testsuite(
srcs = ["memory_errors_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
shard_count = 3,
tags = ["nosan"],
tags = [
"noasan",
"nomsan",
"notsan",
],
deps = [
":testutil",
"//tcmalloc:malloc_extension",
Expand Down Expand Up @@ -493,7 +527,9 @@ create_tcmalloc_testsuite(
copts = TCMALLOC_DEFAULT_COPTS,
linkstatic = 1,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
":testutil",
Expand All @@ -511,7 +547,11 @@ create_tcmalloc_testsuite(
name = "releasing_test",
srcs = ["releasing_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = ["nosan"],
tags = [
"noasan",
"nomsan",
"notsan",
],
deps = [
"//tcmalloc:malloc_extension",
"//tcmalloc/internal:config",
Expand Down Expand Up @@ -610,7 +650,9 @@ create_tcmalloc_testsuite(
srcs = ["realized_fragmentation_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
":testutil",
Expand All @@ -628,7 +670,9 @@ create_tcmalloc_testsuite(
srcs = ["background_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
":test_allocator_harness",
Expand All @@ -644,7 +688,11 @@ create_tcmalloc_testsuite(
name = "reclaim_test",
srcs = ["reclaim_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = ["nosan"],
tags = [
"noasan",
"nomsan",
"notsan",
],
deps = [
":test_allocator_harness",
":thread_manager",
Expand Down Expand Up @@ -684,7 +732,11 @@ create_tcmalloc_testsuite(
name = "deallocation_profiler_test",
srcs = ["deallocation_profiler_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = ["nosan"],
tags = [
"noasan",
"nomsan",
"notsan",
],
deps = [
":testutil",
"//tcmalloc:malloc_extension",
Expand All @@ -702,7 +754,11 @@ cc_test(
srcs = ["system-alloc_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
malloc = "//tcmalloc",
tags = ["nosan"],
tags = [
"noasan",
"nomsan",
"notsan",
],
deps = [
"//tcmalloc:common_8k_pages",
"//tcmalloc:malloc_extension",
Expand All @@ -729,10 +785,7 @@ create_tcmalloc_testsuite(
timeout = "moderate",
srcs = ["tcmalloc_large_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = [
"noasan",
"noubsan",
],
tags = ["noasan"],
deps = [
"//tcmalloc:malloc_extension",
"//tcmalloc/internal:config",
Expand All @@ -748,9 +801,7 @@ cc_test(
srcs = ["malloc_extension_system_malloc_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
malloc = "//tcmalloc/internal:system_malloc",
tags = [
"noubsan",
],
tags = ["noubsan"],
deps = [
"//tcmalloc:malloc_extension",
"@com_google_absl//absl/random",
Expand All @@ -763,7 +814,9 @@ create_tcmalloc_testsuite(
srcs = ["malloc_extension_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
":testutil",
Expand All @@ -781,7 +834,10 @@ cc_test(
local_defines = ["MALLOC_TRACING_EXTENSION_NOT_SUPPORTED"],
malloc = "//tcmalloc/internal:system_malloc",
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
"noubsan",
],
deps = [
"//tcmalloc:malloc_tracing_extension",
Expand All @@ -797,7 +853,9 @@ create_tcmalloc_testsuite(
srcs = ["malloc_tracing_extension_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
"//tcmalloc:malloc_tracing_extension",
Expand All @@ -813,7 +871,9 @@ create_tcmalloc_testsuite(
srcs = ["heap_profiling_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
":test_allocator_harness",
Expand All @@ -840,7 +900,9 @@ cc_test(
copts = TCMALLOC_DEFAULT_COPTS,
malloc = "//tcmalloc",
tags = [
"nosan",
"noasan",
"nomsan",
"notsan",
],
deps = [
"//tcmalloc:malloc_extension",
Expand Down Expand Up @@ -869,9 +931,7 @@ cc_test(
srcs = ["parallel_test.cc"],
copts = TCMALLOC_DEFAULT_COPTS,
malloc = "//tcmalloc/internal:system_malloc",
tags = [
"noubsan",
],
tags = ["noubsan"],
deps = [
"//tcmalloc:malloc_extension",
"//tcmalloc:tcmalloc_internal_methods_only", # buildcleaner: keep
Expand Down

0 comments on commit 49240b3

Please sign in to comment.