Commit Graph

1109 Commits

Author SHA1 Message Date
Sergey Fedorov
8edeea4e83 DefineTargetVariables.cmake: fix for macOS 2023-11-25 16:05:47 +08:00
Sergey Fedorov
68db54545e Minor fix-ups for PowerPC defines 2023-11-25 15:58:24 +08:00
Sergey Fedorov
c815c760da CMakeLists.txt: disable libunwind for ppc 2023-11-25 15:58:24 +08:00
Sergey Fedorov
0ae8fe9650 PCFromUContext.cmake: fix macOS uc_mcontext 2023-11-25 15:27:20 +08:00
Aliaksey Kandratsenka
36fa5ee9ef patch libtool.m4 for compiler_lib_search_path fix for qnx
Amend github issue #1429
2023-11-06 13:51:00 -05:00
Julian Schroeder
000af9a164 [stacktrace_generic_fp] clear aarch64 pointer auth bits
AARCH64 >= armv8.3-a supports pointer authentication. If this feature is
enabled it modifies the previously unused upper address bits in apointer.
The affected bits need to be cleared in order for stacktrace to work.

Signed-off-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[alkondratenko@gmail.com: added succinct subject line]
2023-11-01 13:10:32 -04:00
Aliaksey Kandratsenka
d1a0cbe1bf [qnx] handle broken cfree and mallopt 2023-10-30 19:47:52 -04:00
Xiang.Lin
717bf724a5 Add heap profiler support for QNX 2023-10-30 19:30:37 -04:00
Aliaksey Kandratsenka
adf24f9962 stacktrace_unittest: add simple way to skip ucontext testing 2023-10-27 20:53:21 -04:00
Aliaksey Kandratsenka
4d1a9e9226 stacktrace_unittest: test all stacktrace capturing methods 2023-10-27 19:06:15 -04:00
Aliaksey Kandratsenka
4dc313870c add cmake warning that our support is incomplete 2023-10-27 19:00:17 -04:00
Aliaksey Kandratsenka
96f4f07525 avoid unused variable warning in stacktrace_libunwind 2023-10-27 19:00:17 -04:00
Aliaksey Kandratsenka
db4eacc5d9 avoid runtime initialization of null stacktrace implementation
As we recently found out, initializing static struct fields or
variables with lambdas, sets up runtime initialization instead of
static initialization as we assumed. So lets avoid this too for null
stacktrace implementation.
2023-10-24 15:16:16 -04:00
Yikai Zhao
5ba86d37a3 update stacktrace_unittest to test overflow issue
Signed-off-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
[alkondratenko@gmail.com: squashed log update commit here]
2023-10-19 21:38:01 -04:00
Yikai Zhao
dad9e8ceb9 Fix result overflow in generic_fp stacktrace
In the 'with ucontext' case, the `skip_count` would be reset to 0, and
`max_depth` should not be modified. Otherwise the result array would overflow.
2023-10-19 21:37:45 -04:00
Romain Geissler
c48d4f1407 Avoid initilizing CheckAddress with a lambda, so that it also works with gcc 6. 2023-10-19 14:35:19 -04:00
Aliaksey Kandratsenka
d48bf6b3ad force inline do_mmap_with_hooks
Otherwise mmap calling to do_mmap_with_hooks might tail-call (instead
of inlining), which will then break GetCallerStackTrace
facility (since only mmap is placed into special malloc_hook section).

This unbreaks heap checker on gcc 5, but is in general right thing to
do.
2023-09-27 22:04:31 -04:00
Aliaksey Kandratsenka
9a123db7b4 work around tuple construction miscompilation on gcc 5
This fixes github issue #1432
2023-09-27 22:04:31 -04:00
Yikai Zhao
d152d76cd1 generic_fp stacktrace: check frame size threshold for initial frame 2023-09-25 19:23:10 +08:00
Lennox Ho
64d64bee40 Fix C++ aligned allocation detected in the CMake build 2023-09-22 13:00:25 -04:00
Lennox Ho
589d416977 Add a more performant SpinLockDelay implementation for Windows based on WaitOnAddress and friends 2023-09-19 14:53:16 +08:00
Lennox Ho
fd0fabe183 Fix Windows CMake build by linking page_heap_test and mmap_hook_test to the entire library 2023-09-19 14:47:46 +08:00
Lennox Ho
17f23e8d1e Add the ability to disable TCMalloc replacement on Windows via environment variable TCMALLOC_DISABLE_REPLACEMENT=1 2023-09-18 16:02:07 -04:00
Lennox Ho
df006e880e Also expose SetMemoryReleaseRate and GetMemoryReleaseRate as C shims 2023-09-17 07:59:40 +08:00
Lennox Ho
d3602c0672 Account for Windows while performing implicit TLS detection in CMakeLists.txt 2023-09-17 07:49:38 +08:00
Aliaksey Kandratsenka
dffb4a2f28 bump version to 2.13 2023-09-11 16:23:40 -04:00
Aliaksey Kandratsenka
4ec8c9dbb2 reduce set of nallocx size testing points
Testing every 7th size is a bit slow on slower machines. No need to be
as thorough. We now bump by about 1/128th each step which is still
more steps than size classes we have.
2023-09-10 22:18:51 -04:00
Aliaksey Kandratsenka
e4e7ba93a0 unbreak unnecessary dependency on 64-bit atomics
This unbreaks builds on 32-bit arms and mipsen.
2023-09-10 21:07:28 -04:00
Aliaksey Kandratsenka
523b72f754 make sampling_debug_test actually test debug malloc
We do shell wrapper for actual test run, so we can inspect output of
pprof. But when we set up sampling_debug_test.sh we simply copied
regular sampling_test.sh, which ran same non-debug test binary. Now we
sed-replace contents of shell program when copying, so we test right
binary.

Another thing we fix here is our (still hardcoded) test output path is
now different between sampling{,_debug}_test.sh. So this fixes main
cause of flakiness of our unit tests.
2023-09-10 18:14:57 -04:00
Aliaksey Kandratsenka
2748dd5680 unbreak address access "probing" for generic_fp backtracing
We used msync to verify that address is readable. But msync gives
false positives for PROT_NONE mappings. And we recently got bug report
from user hitting this exact condition.

For correct access check, we steal idea from Abseil and do sigprocmask
with address used as new signal mask and with invalid HOW
argument. This works in today's Linux kernels and is among fastest
methods available. But is brittle w.r.t. possible kernel changes. So
we supply fallback method that does 2 syscalls.

For non-Linux systems we implement usual "write to pipe" trick. Which
also has decent performance, but requires occasional pipe draining and
uses fds which could occasionally be damaged by some forking codes.

We also finally cover all new code with unit test.

Fixes github issue #1426
2023-09-10 17:24:32 -04:00
Ivan Dlugos
7ad1dc7693 fix: cmake config.h defines declaration 2023-09-08 14:38:21 -04:00
Aliaksey Kandratsenka
f7172839a1 turn tcmalloc::TrivialOnce into POD
As we see in github issue #1428, msvc arranges full "init on first
use" initialization for local static usage of TrivialOnce even if that
initialization is completely empty. Fair game, even if stupid.

POD with no initialization should be safely zero-initialized with no
games or tricks from the compilers.

We could have and perhaps at some point should do constexpr for
TrivialOnce and SpinLock (abseil has been liberated from
LinkerInitialized for perphaps well over decade now, including their
fork of SpinLock, of course). But C++ legalese rules are complex
enough and bugs happened in past, so I don't want to be in the tough
business of interpreting standard. So at least for now we keep
things simple.
2023-09-08 14:22:46 -04:00
Aliaksey Kandratsenka
539ed9ca40 bump version 2.12 2023-08-24 15:03:47 -04:00
Aliaksey Kandratsenka
8d634c1f56 don't build mmap_hook when --enable-minimal is given to configure
Refers to github issue #1418
2023-08-24 14:06:25 -04:00
Brett T. Warden
b4ad04982d Set Description field in generated pkg-config files (instead of Summary)
Fixes #1416
2023-08-22 18:09:33 -04:00
Aliaksey Kandratsenka
0a3ca5b43d bump version to 2.11 2023-08-14 22:47:56 -04:00
Aliaksey Kandratsenka
83fccceffa bump README freshness a bit 2023-08-14 22:05:47 -04:00
Ken Raffenetti
c41eb9e8b5 Add MPICH HPC environment detection
Default MPICH builds use the Hydra process manager (mpiexec) which sets
PMI_RANK in the application environment. Update GetUniquePathFromEnv()
test accordingly.

Signed-off-by: Ken Raffenetti <raffenet@mcs.anl.gov>
2023-08-11 15:21:15 -04:00
Aliaksey Kandratsenka
1d2654f3a0 heap-checker: unbreak PTRACE_GETREGS detection on older Linux-es
This unbreaks RHEL6.
2023-08-10 14:30:27 -04:00
Aliaksey Kandratsenka
dbd1071680 link libprofiler with pthread
This unbreaks building on older Linux distros. We missed this at
46d3315ad7 when dropped maybe_thread
stuff, since libprofiler indeed uses pthread, and because on newer
libc-s pthread stuff is now part of regular libc.so.

I am also dropping bogus LIBPROFILER stuff referring to some rpath
badness. Unsure what it was, maybe way back we did libstacktrace as a
proper libtool library, so maybe something was needed. But it is just
a convenience archive this days, so we don't really need to add it
everywhere libprofiler.la is linked.
2023-08-09 23:57:06 -04:00
Aliaksey Kandratsenka
729383b486 make sure that ListerThread runs on properly aligned stack
Without this fix we're failing unit tests on ubuntu 18.04 and centos 7
and 6. It looks like clone() in old glibc-s doesn't align stack, so
lets handle it ourselves. How we didn't hit this much earlier (before
massive thread listing refactoring), I am not sure. Most likely pure
luck(?)
2023-08-09 23:42:56 -04:00
Aliaksey Kandratsenka
51c5e2bec7 massage latest GetUniquePathFromEnv changes
This fixes a number of minor bits (like build details) as well as
making overall code style similar to what we're doing elsewhere.
2023-08-09 16:29:13 -04:00
Artem Polyakov
86450ad99f Add unit test for GetUniquePathFromEnv()
Signed-off-by: Artem Polyakov <artpol84@gmail.com>
2023-08-08 16:44:18 -07:00
Artem Y. Polyakov
881b754da0 Advanced UniquePathFromEnv generation
* Add support for known HPC environments (TODO: needs to be extended
with more nevironments)
* Added the "CPUPROFILE_USE_PID" environment variable to force appending
PID for the non-covered environments
* Preserve the old way of handling the Child-Parent case

Signed-off-by: Artem Polyakov <artpol84@gmail.com>
2023-08-08 16:44:18 -07:00
Aliaksey Kandratsenka
57512e9c3d unbreak -Wthread-safety
It actually found real (but arguably minor) issue with memory region
map locking.

As part of that we're replacing PageHeap::DeleteAndUnlock that had
somewhat ambitious 'move' of SpinLockHolder, with more straightforward
PageHeap::PrepareAndDelete. Doesn't look like we can support move
thingy with thread annotations.
2023-08-06 19:32:32 -04:00
Aliaksey Kandratsenka
862039c185 don't -momit-leaf-frame-pointer when asked for full frame pointers 2023-08-06 14:44:05 -04:00
Aliaksey Kandratsenka
dc25c1fd4c bump version to 2.11rc 2023-07-31 20:11:55 -04:00
Aliaksey Kandratsenka
909fa3e649 unbreak MallocExtension::GetAllocatedSize() for debug allocator
Some years back we fixed memalign vs realloc bug, but we preserved
'wrong' malloc_size/GetAllocatedSize implementation for debug
allocator.

This commit refactors old code making sure we always use right
data_size and it fixes GetAllocatedSize. We update our unittest
accordingly.

Closes #738
2023-07-31 16:28:48 -04:00
Aliaksey Kandratsenka
a51e08b06a drop obsolete TODO file 2023-07-31 15:40:13 -04:00
Aliaksey Kandratsenka
a1c7ce7793 refresh README-s 2023-07-31 15:16:14 -04:00