Commit Graph

405 Commits

Author SHA1 Message Date
Milad Fa
d885e62bc8 PR #2051: Fix absl_stacktrace_test on s390x
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/2051

Commit 33bbc26 made changes to stacktrace_emscripten-inl.inc but did not change the stacktrace_generic-inl.inc file. This caused `absl_stacktrace_test` to fail on s390x.
```
Expected: (results[i]) != (nullptr), actual: NULL vs (nullptr)
Unexpected nullptr found at index 14

[  FAILED  ] StackTrace.NoNullptrInPopulatedRange (0 ms)
```
This patch applies the same logic to stacktrace_generic-inl.inc.
Merge b2fef211b0 into 89203a0303

Merging this change closes #2051

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/2051 from miladfarca:fix-33bbc26 b2fef211b0
PiperOrigin-RevId: 915361786
Change-Id: Iafb02166414df57845410457796758a97bcc253a
2026-05-14 04:36:26 -07:00
Abseil Team
33bbc26609 Break on nullptr return address in UnwindImpl on RISC-V
PiperOrigin-RevId: 914222352
Change-Id: Iff9028a38e878465961f71e90484c2a62ed89132
2026-05-12 05:13:17 -07:00
Mike Kruskal
74b81df26c Fix aarch64 stacktrace unwinding.
PiperOrigin-RevId: 910322805
Change-Id: I7a4b80e306ebfe62f36098376c4e4df396ddb8dc
2026-05-04 17:02:17 -07:00
Abseil Team
852fc61f31 Remove more lingering C++17 type traits polyfill usages
This will let us deprecate the declarations without triggering warnings in Abseil itself.

PiperOrigin-RevId: 906360966
Change-Id: Iee362ac0eac647909ef38003280f1179813f764d
2026-04-27 08:03:53 -07:00
Chris Mihelich
4c5d34c1e5 Document that DemangleRustSymbolEncoding omits some details on purpose.
PiperOrigin-RevId: 888093923
Change-Id: If923d44a1c5c6f6668314499dedf7c52f08b9341
2026-03-23 07:55:14 -07:00
Abseil Team
88c0a25fde Remove the legacy stateless symbol decorator API.
PiperOrigin-RevId: 884958234
Change-Id: I288a4b143718a155663669b7d2e4a24a89d754ec
2026-03-17 05:11:13 -07:00
Abseil Team
842679cdbb Add a stateful version of the SymbolDecorator interface
This makes it possible to make decoration faster by caching some information between runs. Instead of a simple callback a decorator can be a class with a virtual function. This function will not be called concurrently, so it does not need to worry about locking, but it may be called from a signal handler so it must avoid any signal-unsafe operations. The decorator is registered via a factory function, which creates a new object.

Internally, the new decorators are stored inside the ObjFile object and initialized on the first use. If a different factory function is registered, the old decorators are destroyed on the next call to absl::Symbolize.

In order to make the state management simpler, we only support registering a single decorator.

The old interface is left in place to make the migration easier, but it will be removed soon.

PiperOrigin-RevId: 881284709
Change-Id: I25b9db656531fabebd1004f7ec298dc31613b8e3
2026-03-10 01:39:14 -07:00
Mike Kruskal
45c8989b87 Add a visibility placeholder to Abseil for Gloop.
PiperOrigin-RevId: 875292936
Change-Id: I5622f33f8d6581ca3f55783579f612e3e5c4822f
2026-02-25 12:48:48 -08:00
Abseil Team
b6808e6f7c Remove stack trace fixup code from Abseil
PiperOrigin-RevId: 875236816
Change-Id: I88f7d894cc30d23c77b7d43953fe4d85deb65728
2026-02-25 10:48:11 -08:00
Abseil Team
6e0a3164d2 Update *SymbolizeURL APIs to add crash_pc parameter.
PiperOrigin-RevId: 855335009
Change-Id: I1632c5a89e91b857dc18ff9434abf22c3f622d8f
2026-01-12 12:21:10 -08:00
Abseil Team
bbb342c6de Introduce a legacy copy of GetDebugStackTraceHook API.
PiperOrigin-RevId: 852842182
Change-Id: Iadec9bb2fec60b9962a557f82ac998f3cf8d56fe
2026-01-06 10:37:18 -08:00
Abseil Team
d2dd9b9ee9 No public description
PiperOrigin-RevId: 845418157
Change-Id: Iddb10304eaff9c507920eda04f2244e67fdc45cb
2025-12-16 13:45:18 -08:00
Abseil Team
88c48235c8 Search more aggressively for open slots in absl::internal_stacktrace::BorrowedFixupBuffer
This lets us avoid heap allocations in more situations than before.

PiperOrigin-RevId: 841851984
Change-Id: Ibd16b0b87c250c504c8d1119d9b9eb4031067c28
2025-12-08 11:39:05 -08:00
Abseil Team
0cc960ece0 Automated rollback of commit 9f40d6d6f3.
PiperOrigin-RevId: 838084272
Change-Id: I8b1b15618e12cc17d85a71b7f5062b66ceaaf04f
2025-11-29 05:02:02 -08:00
Abseil Team
9f40d6d6f3 Enable clang-specific warnings on the clang-cl build
instead of just trying to be MSVC

This also fixes the new warnings that are caught.
These include:
  * Unreachable code after GTEST_SKIP (this is kind of ugly)
  * Some -Wundef warnings
  * A -Wshadow warning in vlog_config.cc

PiperOrigin-RevId: 838046186
Change-Id: Ief48d6db2b8755d2173997d052560880593d5819
2025-11-29 01:22:25 -08:00
Derek Mauro
b20370e0d6 Enable clang-specific warnings on the clang-cl build
instead of just trying to be MSVC

This also fixes the new warnings that are caught.
These include:
  * Unreachable code after GTEST_SKIP (this is kind of ugly)
  * Some -Wundef warnings
  * A -Wshadow warning in vlog_config.cc

PiperOrigin-RevId: 838017208
Change-Id: I39373c0ccc57c8660c22815c51ac5b4180aec53c
2025-11-28 22:41:40 -08:00
Abseil Team
03cc841ff0 Use non-stack storage for stack trace buffers
Doing this opportunistically allows us to avoid performance overhead in the vast majority of calls (rare, non-reentrant ones) while simultaneously minimizing stack space usage.

PiperOrigin-RevId: 831560881
Change-Id: Idc6ba1dd0dcf1b4aaf3ee7cf468054bcfdcf90af
2025-11-12 15:23:29 -08:00
Abseil Team
c70fe97137 Reduce stack usage when unwinding without fixups
The existing code uses the same stack space regardless of whether fixups are performed. This commit avoids using the stack space in calls that statically bypass fixups, to reduce the potential of a stack overflow.

PiperOrigin-RevId: 830610605
Change-Id: I06168e44e7199e10a606ff634e214ac9a8f9b872
2025-11-10 14:53:12 -08:00
Abseil Team
29d24c5fd3 Reduce stack usage when unwinding from 170 to 128 on x64
PiperOrigin-RevId: 830569454
Change-Id: If5f56cc64ad1f3fe2de45c273b2567ba6ebfe9ed
2025-11-10 13:09:52 -08:00
Abseil Team
7374f9b0f4 Fix typo in macro and add missing static_cast for WASM builds.
Corrects `__asjms__` to `__asmjs__` and adds a `static_cast<size_t>` to the result of `getpagesize() - 1`.

Without this static cast, emscripten based builds will trigger `-Wsign-conversion` on this line.

PiperOrigin-RevId: 827655583
Change-Id: I19b8ed7d3240409127934ac6debcb523fdb73e22
2025-11-03 14:40:09 -08:00
Milad Fa
1a259163cc PR #1961: Fix Clang warnings on powerpc
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1961

We maintain the V8 Js Compiler on IBM platforms which uses abseil as a dependency. We have recently switched to using Clang and need to create this patch to fix two warnings:
```
warning: implicit conversion changes signedness: 'uint64_t' (aka 'unsigned long') to 'int64_t' (aka 'long') [-Wsign-conversion]
warning: implicit conversion loses integer precision: 'uintptr_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
```
Merge 2e972b5c72 into d71fcd13f6

Merging this change closes #1961

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1961 from miladfarca:ppc-fix-clang-warn 2e972b5c72
PiperOrigin-RevId: 823581713
Change-Id: Icff10b99b3808f51866fb97576af405826742088
2025-10-24 10:30:43 -07:00
Abseil Team
f40a1cce40 Optimize stack unwinding by reducing AddressIsReadable calls.
PiperOrigin-RevId: 822738922
Change-Id: Ifd784d16ffb8ae810900b11e41a74ac1f263ed89
2025-10-22 14:22:01 -07:00
Abseil Team
6cdb3d1b38 Add internal API to allow bypassing stack trace fixups when needed
PiperOrigin-RevId: 822668786
Change-Id: I72d6178bbbde8b05b529e2d8297772cbb63758d0
2025-10-22 11:24:12 -07:00
Tom Rybka
067246f7ba Remove usage of the WasmOffsetConverter for Wasm / Emscripten stack-traces.
It was removed in a recent version of [Emscripten](https://github.com/emscripten-core/emscripten/blob/main/ChangeLog.md#4014---090225).

This is unfortunate as there is no longer a way to map from function pointer
(index) back to file offset for PC get function name, however the only such uses I could find were the test itself.

Stack trace symbolization should still work.

PiperOrigin-RevId: 819879868
Change-Id: I5b41d5ebfe5e9f476972e44127bbeaaf2f864281
2025-10-15 13:03:07 -07:00
Derek Mauro
8254d8cf9b Avoid redefine warnings with ntstatus constants
Fixes #1952

PiperOrigin-RevId: 819802635
Change-Id: Ic5ccc1ce61906afbf4ab9e0045b0f54ddaf3be9b
2025-10-15 10:02:25 -07:00
Keith Smiley
2370ccf579 PR #1939: Add missing rules_cc loads
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1939

This is required for use with bazel past this commit: 71ca0ed111

Most files do this already these were just missing

Merge f7d58947af into 620d600442

Merging this change closes #1939

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1939 from keith:ks/add-missing-rules_cc-loads f7d58947af
PiperOrigin-RevId: 809556509
Change-Id: I494a118b851685a03393485514a3b6fbe3a10597
2025-09-20 20:03:14 -07:00
Abseil Team
26c9126028 Fix a corner case in the aarch64 unwinder
In case of two nested back-to-back signals (such as what happens in NestedSignal test) we could end up erroneously using the frame pointer from ucontext_t twice, leading to premature backtrace termination.

In the situation where this happens, the call stack looks like
#0 <unwinder frames>
#1 SigUsr2Handler
#2 __kernel_rt_sigreturn
#3 raise
#4 SigUsr1Handler
#5 __kernel_rt_sigreturn
#6 raise
#7 RaiseSignal
...

When unwinding from #2, we get the fp value from the ucontext (as we should). However, because raise does not modify the fp and because SigUsr1Handler is also a signal handler, when we try to unwind from #4 (#3 is skipped), NextStackFrame ends up looking at the ucontext fp again, and comparing it with the previous (identical) FP value. Non-strict equality accepts this as a valid frame, but the unwinder later bails out due to a zero-sized frame.

Using a strict equality causes NextStackFrame to reject the ucontext fp and use the FP from FP chain instead. This causes us to skip a few more frames, but at least we continue to unwind instead of giving up.

In this case, the computed backtrace skips functions #3, #4 and #6.

PiperOrigin-RevId: 804308754
Change-Id: I5d43e6bea80e4abff1075ada03782ae11c599161
2025-09-08 01:01:51 -07:00
Abseil Team
f8c283dabf Remove support for Native Client
Native Client has been fully removed from Chromium.

PiperOrigin-RevId: 803093147
Change-Id: I7fea87a8a66b35b2f0cc3d815c23f90e5e4d2043
2025-09-04 10:54:42 -07:00
Levi Zim
4dd0ffdf2a PR #1929: Fix shorten-64-to-32 warning in stacktrace_riscv-inl.inc
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1929

`ComputeStackFrameSize` returns `ptrdiff_t` which is `long` while `sizes[n]` is `int`.

This would become an error in chromium build as chromium enables warnings_as_error by default.

Merge ad1d6805b5 into f040e96b93

Merging this change closes #1929

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1929 from kxxt:riscv-int-conversion ad1d6805b5
PiperOrigin-RevId: 802286490
Change-Id: I39526e7f9cc26302a18d329989a6b36ddd487f7c
2025-09-02 14:12:13 -07:00
Abseil Team
72d59c9617 stacktrace_test: avoid spoiling errno in the test signal handler.
PiperOrigin-RevId: 800031515
Change-Id: Ica41c41d176d2ea1ab148e656bf49921098a0411
2025-08-27 07:50:44 -07:00
Abseil Team
5d51d830b6 stacktrace_test: avoid spoiling errno in the test signal handler.
PiperOrigin-RevId: 799655439
Change-Id: I5a06d39bb1188ec305c79ab76a8d0b8d51068dea
2025-08-26 11:56:46 -07:00
Abseil Team
27b1a94353 stacktrace_test: avoid spoiling errno in the test signal handler.
PiperOrigin-RevId: 799631809
Change-Id: I456c0721e56a80a09a510c3556d8aace436717a5
2025-08-26 10:58:49 -07:00
Abseil Team
6b15d34113 Ensure stack usage remains low when unwinding the stack, to prevent stack overflows
PiperOrigin-RevId: 792704790
Change-Id: I4484219d570e84205cf7da95f71e3c8a00a590e8
2025-08-08 11:46:44 -07:00
Abseil Team
fd266b9c35 Shrink #if ABSL_HAVE_ATTRIBUTE_WEAK region sizes in stacktrace_test.cc
PiperOrigin-RevId: 792661664
Change-Id: I72468516ee733529e41bcfdaf783d09a72df3bfe
2025-08-08 09:51:24 -07:00
Abseil Team
11abedd9eb Use signal-safe dynamic memory allocation for stack traces when necessary
This avoids a stack overflow when a large buffer is expected for stack traces.
The small/large threshold we use here is a heuristic to avoid going beyond one page of memory.

PiperOrigin-RevId: 792277857
Change-Id: I2a20ee830175192d0bc61d43ba13d7da10fe7aca
2025-08-07 13:07:41 -07:00
Chris Kennelly
3e0d9ff64a Inline SpinLock Lock->lock, Unlock->unlock internal to Abseil.
PiperOrigin-RevId: 788531193
Change-Id: Icca9ff096c2ec2fc0662f1f94ecfb232a8492974
2025-07-29 11:12:36 -07:00
Milad Fa
471b037ab3 PR #1911: Fix absl_demangle_test on ppc64
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1911

We have recently started experimenting with using Clang to compile abseil (instead of gcc) on ppc64 and this test started failing:
```
# ./bin/absl_demangle_test
abseil-cpp/absl/debugging/internal/demangle_test.cc:1996: Failure
Expected: (stack_consumed) < (kStackConsumptionUpperLimit), actual: 9668 vs 8192

[  FAILED  ] Demangle.DemangleStackConsumption (5 ms)
```
This PR increases the value of `kStackConsumptionUpperLimit` to accommodate higher stack usage.
Merge fb14c03227 into 7ece455c25

Merging this change closes #1911

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1911 from miladfarca:ppc-fix-test fb14c03227
PiperOrigin-RevId: 787192848
Change-Id: I1343b9a22a92e5663e6e27e827c7b0584800ebbc
2025-07-25 12:04:17 -07:00
Abseil Team
342afd0767 Deduplicate stack trace implementations in stacktrace.cc
PiperOrigin-RevId: 786730361
Change-Id: I8184cd8a259570ff247077d7e3adaf430bd08ecc
2025-07-24 09:21:06 -07:00
Abseil Team
6ad95e1535 Move SigSafeArena() out to absl/base/internal/low_level_alloc.h
This allows dynamic memory allocation for computing stack traces to avoid a stack overflow.

PiperOrigin-RevId: 786512779
Change-Id: Ib5ef8fef436672b99d9678137e3b2bb65ca47eba
2025-07-23 19:13:04 -07:00
Krzysztof Kosiński
454205a618 Roll back NDK weak symbol mode for backtrace() due to internal test breakage
PiperOrigin-RevId: 784690676
Change-Id: Ief3ebd9f6850594b530992867a0642fca6525fdc
2025-07-18 13:53:18 -07:00
Abseil Team
f2dd73d7a8 Allocate memory for frames and sizes during stack trace fix-up when no memory is provided
PiperOrigin-RevId: 784266735
Change-Id: I537a6472ce284e97734d56ccff1863108ed3eb39
2025-07-17 12:08:54 -07:00
Krzysztof Kosiński
9f1244cb3f Support NDK weak symbol mode for backtrace() on Android.
Allows code compiled for API level 32 or lower to support backtrace() when it runs on API level 33 or higher.

PiperOrigin-RevId: 783954794
Change-Id: Ie3e2552d4625092fe5750f6d2d64ae78597d97c3
2025-07-16 17:24:19 -07:00
Krzysztof Kosiński
af00a9295f Only use generic stacktrace when ABSL_HAVE_THREAD_LOCAL.
The file uses __thread, so it should not be included when thread-local storage is not available.

PiperOrigin-RevId: 783193545
Change-Id: I64ca0fde08d2aa0e478d75f3d5fbb3a5bfcea452
2025-07-14 23:14:19 -07:00
Abseil Team
2b320cbfaa Fix includes and fuse constructors of SpinLock.
PiperOrigin-RevId: 774835829
Change-Id: I0fa7cab1b98c1b7222de0acd71b7846df693f1e2
2025-06-23 10:32:42 -07:00
Abseil Team
f8c9a088d6 Suppress CFI violation on VDSO call.
PiperOrigin-RevId: 767658852
Change-Id: I097433844dd6f4db0c9c0fdc0b3f5dd0dcc5ee63
2025-06-05 10:10:05 -07:00
Wiktor Garbacz
d55845e6c1 stacktrace_x86: Handle nested signals on altstack
PiperOrigin-RevId: 758147101
Change-Id: I569e095b4820862a7ebba68bd22ab205f43693e2
2025-05-13 03:49:25 -07:00
Peter Collingbourne
1b52dcb350 Stop being strict about validating the "clone" part of mangled names
Support for parsing mangled symbol names with a ".something" suffix
in the demangler was originally added because the compiler was using
that for function cloning, but since then the compiler has started
using ".something" suffixes in many other cases, such as function
renaming for ThinLTO and CFI. As a result, some symbols in binaries
built with these features would fail to demangle.

So instead of trying to validate what comes after the "." let's just
stop parsing when we see a ".", so that the symbols are demangled
correctly. This behavior is consistent with libc++.

PiperOrigin-RevId: 756054147
Change-Id: I01e9e97eee32bee05ba243b615ed26a36b59591d
2025-05-07 16:38:36 -07:00
Derek Mauro
668f174945 Fix new -Wnullability-completeness warnings found after upgrading
the Clang version used in the Linux ARM CI to Clang 19.

nullability-completeness is an all-or-nothing warning, and it is
enabled by default. If anything is annotated, everything has to be
annotated.

There are a few types of fixes in this change. The most common is just
to add missing annotations. In a few cases, some SFINAE methods are
changed not to use pointers at all. In some cases, like
cord_internal.h, I removed the single annotation as that is easier
than doing the entire complicated file for now. cordz_test_helpers.h
uses GoogleTest macros, which bring in pointers that can't easily be
annotated, so I removed the annotations from this file as well.
Tests are also opted-out of the warning.

I'm not sure why the x86 Clang version didn't pick these issues up.

PiperOrigin-RevId: 755844859
Change-Id: I7d7f4cc4f6d779f52c86a4d96e07880341244491
2025-05-07 07:28:51 -07:00
Abseil Team
a9a1b50468 Assume that frame pointers inside known stack bounds are readable.
AddressIsReadable is an expensive check, and in non-crash unwinding situations
always returns true. Avoid that cost.

This is less conservative than the current code. If the known stack
bounds (as returned by a different syscall) are unreadable, the new
code will double fault instead of truncating the returned stack. So some
really bad crash situations will double fault instead of truncating.
Normal stack unwinding will be considerably faster.

PiperOrigin-RevId: 753323325
Change-Id: I4ca90f261ecbe90a12823f832ee9de1bfabecd61
2025-04-30 14:56:20 -07:00
Michael Pratt
fe5a2a4414 Fix misplaced closing brace
6dda8e527f attempted to move this check from the
WITH_CONTEXT block to the main part of the function, but it mistakenly moved
the unrelated brace following the if block.

The result is that the `if (WITH_CONTEXT ...) { ... }` scope actually contains
the alignment and readable checks. When `WITH_CONTEXT` is false, those checks
never run.

PiperOrigin-RevId: 752400908
Change-Id: Ida50d613f4124bc187af1a301bd92439d07a56ee
2025-04-28 12:16:46 -07:00