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
This will let us deprecate the declarations without triggering warnings in Abseil itself.
PiperOrigin-RevId: 906360966
Change-Id: Iee362ac0eac647909ef38003280f1179813f764d
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
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
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
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
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
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
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
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
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
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
The file uses __thread, so it should not be included when thread-local storage is not available.
PiperOrigin-RevId: 783193545
Change-Id: I64ca0fde08d2aa0e478d75f3d5fbb3a5bfcea452
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
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
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
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
Together with the frame sizes already being returned, this gives us the bounds on each stack frame.
Note that this may slightly affect MSVC in debug builds, as it does not respect ABSL_ATTRIBUTE_ALWAYS_INLINE without optimizations. To remedy this, either enable inlining (/Ob1 or higher), or write a wrapper that ensures any stack traces obtained are robust to frames being added (such as by manually filtering everything below the caller).
Do not depend on the new APIs publicly. They are subject to change or removal.
PiperOrigin-RevId: 740075920
Change-Id: I6cd0909e7be3af4c9f32d39633230f655946b6a8
The overflow can happen during rollback after a parsing
failure, where the null terminator is written without
verifying the buffer bounds.
Credit to www.code-intelligence.com for reporting this issue
PiperOrigin-RevId: 732995553
Change-Id: Ic5075f53e510d270e1784d593defcd53f9121d02
In this change, //absl/status is intentionally excluded because of
complication with SWIG compatibility. This may be handled separately.
PiperOrigin-RevId: 731387819
Change-Id: I71bf2e02f3a477d65575d467f5e5ab163846d31e
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1783
Today we cannot build V8 (which uses the Abseil library) in strict mode for RISC-V due to a few warnings in debbugging inlines. All the warnings are about implicit signed to unsigned conversion and precision losses, nothing serious, but they are still very annoying.
Merge 7b2a865021 into 8596c6e7f5
Merging this change closes#1783
COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1783 from apavlyutkin:riscv-fix-warnings 7b2a865021
PiperOrigin-RevId: 693802454
Change-Id: Ibfefc9370606a6b8ec217ac6d87d7c6d70d1a3ce
This change adds support for unwinding stack traces on supported android platforms (NDK 33+) to absl::GetStackTrace().
PiperOrigin-RevId: 668041186
Change-Id: Ie4c4c123686050c6b81683b71fe0246e8fa75f2b
This library provides `LookupSymbol` and `LookupSymbolByAddress`. The latter
needs `GetNumSymbols` support. An object file needs either .hash (DT_HASH) or
.gnu.hash (DT_GNU_HASH). This patch adds DT_GNU_HASH support.
Note: glibc has been supporting DT_GNU_HASH since 2006 and .hash has been quite
obsoleted in the Linux communities.
PiperOrigin-RevId: 648459622
Change-Id: I3aa1274cd4617990844258175715e3be2343afd2