Repository navigation
Closed
Description
What
The unit test //tcmalloc/testing:background_test_no_glibc_rseq reliably fails since the linux commit 39a167560a61 ("rseq: Optimize event setting").
This was discussed on this archlinux issue. It was also discussed on the kernel mailing list. The latter thread also says:
Is this using tcmalloc? If so, that is somewhat expected because
tcmalloc is known to violate upstream rseq ABI. IIRC you should get a
nice splat if you enable rseq debug mode (echo 1 > /debug/rseq/debug).Perhaps this is the nudge Google needs to go fix this.
Failing unit test:
[arch@podman-mongodb tcmalloc]$ GLIBC_TUNABLES=glibc.pthread.rseq=1 bazel-bin/tcmalloc/testing/background_test_no_glibc_rseq
[==========] Running 2 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 2 tests from BackgroundTest
[ RUN ] BackgroundTest.Defaults
[ OK ] BackgroundTest.Defaults (0 ms)
[ RUN ] BackgroundTest.Stress
[ OK ] BackgroundTest.Stress (10017 ms)
[----------] 2 tests from BackgroundTest (10018 ms total)
[----------] Global test environment tear-down
[==========] 2 tests from 1 test suite ran. (10018 ms total)
[ PASSED ] 2 tests.
[arch@podman-mongodb tcmalloc]$ GLIBC_TUNABLES=glibc.pthread.rseq=0 bazel-bin/tcmalloc/testing/background_test_no_glibc_rseq
[==========] Running 2 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 2 tests from BackgroundTest
[ RUN ] BackgroundTest.Defaults
[ OK ] BackgroundTest.Defaults (0 ms)
[ RUN ] BackgroundTest.Stress
14207 ./tcmalloc/internal/percpu_tcmalloc.h:852] CHECK in Pop: next (false)
Aborted (core dumped) GLIBC_TUNABLES=glibc.pthread.rseq=0 bazel-bin/tcmalloc/testing/background_test_no_glibc_rseq
[arch@podman-mongodb tcmalloc]$ GLIBC_TUNABLES=glibc.pthread.rseq=0 /tmp/bazel test //tcmalloc/testing:background_test_no_glibc_rseq
WARNING: Build option --test_env has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
INFO: Analyzed target //tcmalloc/testing:background_test_no_glibc_rseq (0 packages loaded, 5304 targets configured).
FAIL: //tcmalloc/testing:background_test_no_glibc_rseq (Aborted) (see /home/arch/.cache/bazel/_bazel_arch/3c882abdfeb0a7dc4942cd1a7209754a/execroot/_main/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/background_test_no_glibc_rseq/test.log)
INFO: Found 1 test target...
Target //tcmalloc/testing:background_test_no_glibc_rseq up-to-date:
bazel-bin/tcmalloc/testing/background_test_no_glibc_rseq
INFO: Elapsed time: 3.948s, Critical Path: 1.62s
INFO: 2 processes: 644 action cache hit, 2 linux-sandbox.
INFO: Build completed, 1 test FAILED, 2 total actions
//tcmalloc/testing:background_test_no_glibc_rseq FAILED in 1.6s
/home/arch/.cache/bazel/_bazel_arch/3c882abdfeb0a7dc4942cd1a7209754a/execroot/_main/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/background_test_no_glibc_rseq/test.log
Executed 1 out of 1 test: 1 fails locally.
[arch@podman-mongodb tcmalloc]$ cat /home/arch/.cache/bazel/_bazel_arch/3c882abdfeb0a7dc4942cd1a7209754a/execroot/_main/bazel-out/k8-fastbuild/testlogs/tcmalloc/testing/background_test_no_glibc_rseq/test.log
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //tcmalloc/testing:background_test_no_glibc_rseq
-----------------------------------------------------------------------------
[==========] Running 2 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 2 tests from BackgroundTest
[ RUN ] BackgroundTest.Defaults
[ OK ] BackgroundTest.Defaults (0 ms)
[ RUN ] BackgroundTest.Stress
28 ./tcmalloc/internal/percpu_tcmalloc.h:852] CHECK in Pop: next (false)
*** SIGABRT received at time=1773167104 on cpu 1 ***
23 ./tcmalloc/internal/percpu_tcmalloc.h:852] CHECK in Pop: next (false)
[failure_signal_handler.cc : 377] RAW: Signal 6 raised at PC=0x7f7d81d89a2c while already in AbslFailureSignalHandler()
19 ./tcmalloc/internal/percpu_tcmalloc.h:852] CHECK in Pop: next (false)
[failure_signal_handler.cc : 377] RAW: Signal 6 raised at PC=0x7f7d81d89a2c while already in AbslFailureSignalHandler()
[failure_signal_handler.cc : 377] RAW: Signal 11 raised at PC=0x5580fdd87519 while already in AbslFailureSignalHandler()
[failure_signal_handler.cc : 377] RAW: Signal 11 raised at PC=0x5580fdd87519 while already in AbslFailureSignalHandler()
20 ./tcmalloc/internal/percpu_tcmalloc.h:852] CHECK in Pop: next (false)
[failure_signal_handler.cc : 377] RAW: Signal 6 raised at PC=0x7f7d81d89a2c while already in AbslFailureSignalHandler()
PC: @ 0x7f7d81d89a2c (unknown) (unknown)
@ 0x7f7d82ae1c35 64 absl::lts_20260107::WriteFailureInfo()
@ 0x7f7d82ae1e74 96 absl::lts_20260107::AbslFailureSignalHandler()
@ 0x7f7d81d2f2d0 3120 (unknown)
@ 0x7f7d81d2f1a0 32 raise
@ 0x7f7d81d165fe 192 abort
@ 0x7f7d826b2d8d 704 tcmalloc::tcmalloc_internal::Crash()
@ 0x7f7d826b2dc2 48 tcmalloc::tcmalloc_internal::CheckFailed()
@ 0x5580fdc850a2 640 tcmalloc::tcmalloc_internal::CheckFailed<>()
@ 0x5580fdd78ab6 368 operator new()
@ 0x5580fdb7bc44 64 std::__new_allocator<>::allocate()
@ 0x5580fdb7a3a3 48 std::_Vector_base<>::_M_allocate()
@ 0x5580fdb7a5d1 256 std::vector<>::_M_realloc_append<>()
@ 0x5580fdb7934a 128 std::vector<>::emplace_back<>()
@ 0x5580fdb77c6d 48 std::vector<>::push_back()
@ 0x5580fdb76395 208 tcmalloc::AllocatorHarness::Run()
@ 0x5580fdb73d9d 32 tcmalloc::(anonymous namespace)::BackgroundTest_Stress_Test::TestBody()::{lambda()#1}::operator()()
@ 0x5580fdb74466 48 std::__invoke_impl<>()
@ 0x5580fdb74354 48 std::__invoke_r<>()
@ 0x5580fdb7421b 64 std::_Function_handler<>::_M_invoke()
@ 0x5580fdb78128 32 std::function<>::operator()()
@ 0x5580fdb76b50 32 tcmalloc::ThreadManager::Start()::{lambda()#1}::operator()()
@ 0x5580fdb7eba2 48 std::__invoke_impl<>()
@ 0x5580fdb7eaf2 48 std::__invoke<>()
@ 0x5580fdb7ea49 64 std::thread::_Invoker<>::_M_invoke<>()
@ 0x5580fdb7e9e6 32 std::thread::_Invoker<>::operator()()
@ 0x5580fdb7e9aa 32 std::thread::_State_impl<>::_M_run()
@ 0x7f7d820e55a4 32 (unknown)
@ 0x7f7d81d8797a 224 (unknown)
@ 0x7f7d81e0b2bc (unknown) (unknown)Reacted by Denis Frenademetz, Theo Paris, Alexander Skovpen, Alexey Murz Korepov and Vicenç Juan Tomàs Montserrat
Metadata
Metadata
Assignees
Labels
No labels
Activity
maratik123 commentedon Mar 13, 2026
Let me left it here: https://lkml.org/lkml/2012/12/23/75
sakaru commentedon Mar 13, 2026
I think I already addressed this by quoting the mailing list. tcmalloc (reportedly, I'm no expert) does not abide by the rseq ABI, thus the "WE DO NOT BREAK USERSPACE!" does not apply.
ckennelly commentedon Mar 14, 2026
TCMalloc has had a per-CPU slab caching optimization since around aaa4fbf in September 2023. It shortens the critical path of malloc operations, and finding an alternative that preserves the performance benefits may prove challenging.
There was a prior discussion regarding the slab caching optimization in #144, fwiw.
dvyukov commentedon Mar 16, 2026
This test fails for me on both v6.17 and v6.6 kernels in the same way...
lvoytek commentedon Mar 30, 2026
Hello, I am working on the Ubuntu 26.04 release with kernel 7.0 and was pinged about this today. We were wondering what the tcmalloc maintainers believe the impact of this may be. We currently use tcmalloc for several applications in the Ubuntu archive, including MySQL 8.4 since 25.10 (kernel 6.17). I experimented with MySQL on the 26.04 beta today with kernel 7.0 and did not hit any issues. Could you confirm if we should be concerned about this issue outside of MongoDB, or just consider this to be a normal bug to track for a fix later on?
ckennelly commentedon Mar 31, 2026
It appears that torvalds/linux@39a1675 changed the behavior of the
membarriersyscall.Previously,
membarriercaused the kernel to overwrite fields like__rseq_abi.cpu_idand__rseq_abi.cpu_id_start.Since that change,
membarrieralone is not sufficient, which breaks our cross-CPU fencing operations.We are looking at potential fixes that can be done entirely inside TCMalloc, but this is an upstream change that broke userspace.
askovpen commentedon Apr 24, 2026
Yesterday released Ubuntu 26.04 LTS with kernel 7.0. All software, uses this lib will not work
sakaru commentedon Apr 24, 2026
I realise you are likely not the one who wrote the MongoDB release notes. I do want to stress something I included in the initial post though; setting
GLIBC_TUNABLES=glibc.pthread.rseq=1is a workaround, though I don't know what other consequences that has (perhaps performance regressions).I installed Ubuntu 26.04 just now, and MongoDB is not packaged in the repositories, but I tried running it via docker. Running the latest tags fails because of a hardcoded kernel version check1, but older containers which don't have that restriction work with that tunable set.
So MongoDB would work with that environment variable set. Again with the caveat that I don't know what other consequences that entails.
Footnotes
https://github.com/mongodb/mongo/blob/cd90f28f0a69ab94a913fb5310a69a7602e2f107/src/mongo/db/startup_check_rseq.cpp#L97-L107 ↩
dvyukov commentedon Apr 25, 2026
FTR potential fixes or revert is discussed on the kernel mailing lists:
https://lore.kernel.org/all/CAHnCjA25b+nO2n5CeifknSKHssJpPrjnf+dtr7UgzRw4Zgu=oA@mail.gmail.com/
askovpen commentedon Apr 25, 2026
latest mongodb stable release:
antonio-giovannetti commentedon Apr 27, 2026
Hello, are you planning to fix the issue? It blocks upgrade to mongodb 8, see issue
ckennelly commentedon Apr 30, 2026
There's a patch series out for fixing this in the kernel: https://lkml.org/lkml/2026/4/29/73
6.19 introduced a number of regressions: membarrier trigger republish of
cpu_id_start, lack of mutual exclusion on AArch64, and some more minor ones (settingcpu_id_start=0on unregister)askovpen commentedon May 15, 2026
#292 (comment) this patch in:
https://cdn.kernel.org/pub/linux/kernel/v7.x/ChangeLog-7.0.7
what's next?
sakaru commentedon May 15, 2026
It is not patched in linux 7.0.7. Commit b9eac6a is not included in that release. It does not apply cleanly1. The patch will likely be part of linux 7.1, though perhaps some distros will backport the patch. I can confirm that on kernel 7.1.0-rc3 it works2.
As for what next: Nothing for tcmalloc. Downstream projects (such as MongoDB) will need to update their docker images to use the newer kernels and their documentation regarding kernel version support.
Footnotes
https://lore.kernel.org/stable/2026051256-posture-repost-4c65@gregkh/ ↩
it being
mongodb-community-server:8.0.19-ubi9, since I don't want to set up the tcmalloc test suite again, and newer images reject running on such new kernels. ↩tyilo commentedon May 15, 2026
Docker images uses the host's kernel.
3 remaining items
kvaster commentedon May 22, 2026
Sounds like tcmalloc team doesn't care.... I'd keep it open.
LucaDev commentedon May 22, 2026
The tcmalloc team "doesn't care" because its a kernel bug. What should they do? Patches are rolling out soon.
Or in Linus Torvalds words: "WE [THE KERNEL] DONT BREAK USERSPACE" (https://lkml.org/lkml/2012/12/23/75)
kvaster commentedon May 22, 2026
It looks more like: we should not break wrong userspace usage because it affects lot's of users, but it would be good for tcmalloc to solve the problem in a right way.
This is a BIG workaround in a kernel for tcmalloc which is widely used.
intersectRaven commentedon May 23, 2026
It served as a hard lesson to the kernel devs (RSEQ devs in particular) that, as Linus puts it:
"This is why system calls and ABI's need to have hard rules that they
actually check, because if they don't, they are stuck with the
semantics that people assume."
In the future, they should be more proactive in checking everything is used as they should.
As for the tcmalloc people, what they do about it is their prerogative. From what I've read, going to the v2 RSEQ implementation yields some performance advantages but as I'm not familiar with tcmalloc, whether it's worth it to go there in the future is up to them. At least we have even more documentation now about it in this issue and related issues that maybe they can show to their managers to motivate them to at least investigate.
askovpen commentedon May 23, 2026
https://cdn.kernel.org/pub/linux/kernel/v7.x/ChangeLog-7.0.10
dvyukov commentedon Jun 1, 2026
FYI the kernel fixes have introduced a security vulnerability that allows unprivileged processes to fetch sensitive intimation from the kernel or other processes:
https://lore.kernel.org/all/[email protected]/T/
If you have the fixes, you may want to cherry-pick the fix for the kernel information leak:
https://lore.kernel.org/all/[email protected]/T/
[yugabyte#34543] yugabyted: Use glibc.pthread.rseq=1 on kernels 6.19.…
[yugabyte#34542] DocDB: Report inactive TCMalloc per-CPU caches and r…
[yugabyte#34543] yugabyted: Use glibc.pthread.rseq=1 on kernels 6.19.…
[yugabyte#34545] Docs: Document GLIBC_TUNABLES=glibc.pthread.rseq=0 f…
[yugabyte#34542] DocDB: Report inactive TCMalloc per-CPU caches and r…
[yugabyte#34542] DocDB: Report inactive TCMalloc per-CPU caches and r…
[yugabyte#34543] yugabyted: Set glibc.pthread.rseq for the servers it…
[#34543] yugabyted: Set glibc.pthread.rseq for the servers it starts (#…