Commit Graph

1128 Commits

Author SHA1 Message Date
Aliaksey Kandratsenka
d5c1edf4f5 [cmake] explicitly link more libraries for threading
See discussion on https://github.com/gperftools/gperftools/pull/1473
2024-01-03 16:07:16 -05:00
Aliaksey Kandratsenka
9430287d15 few editorial fixes to NEWS for 2.14 release 2024-01-01 12:38:26 -05:00
Aliaksey Kandratsenka
dcf0131055 correct NEWS entry about QNX (it supports heap profiler) 2024-01-01 01:03:05 -05:00
Aliaksey Kandratsenka
e49b36f7d6 bump version to 2.14 2023-12-31 23:17:03 -05:00
Aliaksey Kandratsenka
f17d54df5c add recently added getpc-inl.h to a set of headers to package 2023-12-31 23:17:03 -05:00
Aliaksey Kandratsenka
fae6421668 avoid unused variable warning for TCMallocImplementation space 2023-12-31 23:17:03 -05:00
Aliaksey Kandratsenka
1ba9f60579 construct malloc extension instances in static spaces
So that malloc hooks can call into
MallocExtension::instance()->GetAllocatedSize() and avoid recursion
from new MallocExtension call inside that call.

This was proposed by github user poljak181 at issue #1472
2023-12-31 22:05:43 -05:00
Aliaksey Kandratsenka
a0880d78f3 Revert "[osx] implement native c++ allocation operators on osx"
This reverts commit 6683e4f6ee.
2023-12-31 21:33:30 -05:00
Aliaksey Kandratsenka
6299ae9869 test PREFER_LIBGCC_UNWINDER via defined()
Our newly updated cmake bits now define it to empty, when it is
enabled, so we want to test it right. Autoconf stuff behaves the same
as before.
2023-12-31 21:23:43 -05:00
Mateusz Jakub Fila
bbc03edc4d added missing aggressive decommit option in cmake 2023-12-27 01:58:46 +01:00
Mateusz Jakub Fila
9c2028ae50 added missing large alloc report option in cmake 2023-12-27 01:58:34 +01:00
Mateusz Jakub Fila
eeb25dd2a5 added missing finding asm/ptrace.h in cmake 2023-12-27 01:58:25 +01:00
Mateusz Jakub Fila
4e9fd729d2 added missing finding HAVE___ATTRIBUTE__ALIGNED_FN in cmake 2023-12-27 01:58:11 +01:00
Mateusz Jakub Fila
ad4a6ff8de added missing gcc unwinder preference option in cmake 2023-12-27 01:57:46 +01:00
Mateusz Jakub Fila
8987d08f79 fixed setting pagesize and pageshift in cmake 2023-12-24 01:51:00 +01:00
barracuda156
e9a2d3c46f mmap_hook.cc: use MAP_ANON when MAP_ANONYMOUS is not defined 2023-12-16 10:46:57 +08:00
Aliaksey Kandratsenka
85048430ac consolidate do_mallinfo{,2}
We had 2 nearly identical implementations. Thankfully C++ templates
facility lets us produce 2 different runtime functions (for different
type widths) without duplicating source.

Amend github issue #1414
2023-12-07 15:01:27 -05:00
Mateusz Jakub Fila
b8e75ae6fe Add mallinfo2 function 2023-12-07 14:10:51 +01:00
Aliaksey Kandratsenka
a9b734e3fa perform ucontext->pc variants testing in compile-time
As part of cpu profiler we're extracting current PC (program counter)
of out signal's ucontext. Different OS and hardware combinations have
different ways for that. We had a list of variants that we tested at
compile time and populated PC_FROM_UCONTEXT macro into config.h. It
caused duplication and occasional mismatches between our autoconf and
cmake bits.

So this commit changes testing to be compile-time. We remove
complexity from build system and add some to C++ source.

We use SFINAE to find which of those variants compile (and we silently
assume that 'compiles' implies 'works'; this is what config-time
testing did too). Occasionally we'll face situations where several
variants compile. And we couldn't handle this case in pure C++. So we
have a small Ruby program that generates chain of inheritance among
SFINAE-specialized class templates. This handles prioritization among
variants.

List of ucontext->pc extraction variants is mostly same. We dropped
super-obsolete (circa Linux kernel 2.0) arm variant. And NetBSD case
is now improved. We now use their nice architecture-independent macro
instead of x86-specific access.
2023-12-02 18:58:45 -05:00
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