From 4b00385927c94b9b307b02b2d3665d01831b68bb Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Fri, 10 Nov 2023 14:36:39 -0800 Subject: [PATCH] tests: don't change malloc for tests system_malloc is causing test flakes. The issue with tcmalloc is it isn't fork-safe and any allocations in forked sub-processes can stuck. PiperOrigin-RevId: 581372831 --- test/syscalls/linux/BUILD | 2 ++ tools/bazeldefs/cc.bzl | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/syscalls/linux/BUILD b/test/syscalls/linux/BUILD index 71540490e..9f3f53920 100644 --- a/test/syscalls/linux/BUILD +++ b/test/syscalls/linux/BUILD @@ -4649,6 +4649,8 @@ cc_binary( testonly = 1, srcs = ["process_vm_read_write.cc"], linkstatic = 1, + # tcmalloc isn't fork-safe. + tcmalloc = False, deps = [ gtest, "//test/util:logging", diff --git a/tools/bazeldefs/cc.bzl b/tools/bazeldefs/cc.bzl index 57d33726a..d13ede510 100644 --- a/tools/bazeldefs/cc.bzl +++ b/tools/bazeldefs/cc.bzl @@ -26,12 +26,13 @@ cc_flags_supplier = rule( def cc_grpc_library(name, **kwargs): _cc_grpc_library(name = name, grpc_only = True, **kwargs) -def cc_binary(name, static = False, **kwargs): +def cc_binary(name, static = False, tcmalloc = False, **kwargs): """Run cc_binary. Args: name: name of the target. static: make a static binary if True + tcmalloc: use TCMalloc if True (not implemented) **kwargs: the rest of the args. """ if static: @@ -46,6 +47,10 @@ def cc_binary(name, static = False, **kwargs): "-lpthread", "-Wl,--no-whole-archive", ] + if tcmalloc: + # buildifier: disable=print + print("Warning: tcmalloc can't be enabled") + _cc_binary( name = name, **kwargs