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
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
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
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
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
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
This allows dynamic memory allocation for computing stack traces to avoid a stack overflow.
PiperOrigin-RevId: 786512779
Change-Id: Ib5ef8fef436672b99d9678137e3b2bb65ca47eba
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