Commit Graph

1196 Commits

Author SHA1 Message Date
Aliaksei Kandratsenka
2e6061d07a function_ref: enable construction from pair of function and data 2024-10-15 18:45:51 -04:00
Aliaksei Kandratsenka
3f04893eee unbreak tcmalloc::FunctionRefFirstDataArg 2024-10-15 18:45:46 -04:00
Aliaksei Kandratsenka
8560276997 have atfork handler also handle SlowTLS and SysAllocator locks
Referenced github issue #1570 and github issue #1425

This enables "minimal" allocator to pass fork torture testing.
2024-10-15 18:21:03 -04:00
Aliaksei Kandratsenka
dd043fefb9 implement fork torture testing
I.e. so that we can exercise malloc in forked child.

Referenced github issue #1570 and github issue #1425
2024-10-15 18:21:03 -04:00
Aliaksei Kandratsenka
6e4984bc1b [symbolize] generalize API and implementation 2024-10-07 13:21:11 -04:00
Aliaksei Kandratsenka
03d361bff8 [debugallocation_test] simplify diagnosing backtrace dumping test
I.e. by having TCM_DEBUG_BT_SYMBOLIZATION_TEST that disables death
test and just runs "death" actions directly. So that someone can gdb
symbolization part.
2024-10-07 13:18:59 -04:00
Aliaksei Kandratsenka
fe5127bac5 dont include useless .deps directories into make dist archives
We do arguably a bit reckless thing with simply packaging entire
vendor/ subdirectory and that gives us some crap. But for now this is
what we'll do and we'll simply remove that "crap" as part of packaging
step.
2024-10-05 11:03:57 -04:00
Aliaksei Kandratsenka
99da87d086 unbreak compilation on gcc-7 2024-10-05 11:03:53 -04:00
Aliaksei Kandratsenka
1f7f60d5c2 [low_level_alloc_unittest] fix lack of override specifier
As correctly warned by clang.
2024-10-05 10:40:24 -04:00
Aliaksei Kandratsenka
a836930deb [symbolize] call backtrace_syminfo when pcinfo fails
This is how we need to deal with symbols without line numbers debug
info. It unbreaks for example _start symbolization.

We also refactor the code some and we run symbolization with
emergency malloc mode enabled.
2024-10-04 19:38:46 -04:00
Aliaksei Kandratsenka
9c8aeab54a [emergency_malloc] support GetAllocatedSize on emergency allocations
This enables OSX to do usual malloc/free things in emergency malloc
mode. We update unit tests accordingly (i.e. call free instead of
tc_free when relevant).
2024-10-04 19:38:46 -04:00
Aliaksei Kandratsenka
d5055ef3a2 new symbolize api and implementation
This is part of effort to get rid of perl pprof dependency. We're
replacing forking to pprof --symbols with carefully crafted
libbacktrace integration which has enough support for symbolizing
backtraces.
2024-10-03 21:18:04 -04:00
Aliaksei Kandratsenka
96885311f3 add vendor/libbacktrace 2024-10-03 21:17:51 -04:00
Aliaksei Kandratsenka
94da1c10f9 cleanup unused symbolize.cc from msvc project files 2024-10-03 21:17:51 -04:00
Aliaksei Kandratsenka
acb9f66460 place LowLevelAlloc into tcmalloc namespace 2024-10-03 20:42:26 -04:00
Aliaksei Kandratsenka
40957460b5 [low_level_alloc] allocate Arena with custom allocator when provided
This refactors API so that meta_data_arena isn't needed or used
anymore. We always used nullptr for this argument anyways.

We also change code so that PagesAllocator API is able to choose
rounding up of allocation requests. It now returns pointer to
allocated memory and it's rounded up size.

And most important part of this change is that Arena instance itself
is now allocated with provided allocator (when provided). This reduces
locking depencies.

We make sure to cover new logic by test.
2024-10-03 20:42:26 -04:00
Aliaksei Kandratsenka
d0d4363a34 structure low_level_alloc as own convenience archive 2024-10-03 17:06:22 -04:00
Aliaksei Kandratsenka
3c261d9090 stop linking malloc_hooks to low_level_alloc 2024-10-03 16:56:53 -04:00
Andrey Semashev
2e1799aa78 Fix gcc 10 compilation error
Apparently, gcc 10 doesn't support trailing return types for lambdas with an attribute.

```
src/tests/sampling_test.cc: In lambda function:
src/tests/sampling_test.cc:70:56: error: expected '{' before '->' token
   70 |   auto local_noopt = [] (void* ptr) ATTRIBUTE_NOINLINE -> void* {
      |                                                        ^~
src/tests/sampling_test.cc: In function 'void* AllocateAllocate()':
src/tests/sampling_test.cc:70:56: error: base operand of '->' has non-pointer type 'AllocateAllocate()::<lambda(void*)>'
src/tests/sampling_test.cc:70:59: error: expected unqualified-id before 'void'
   70 |   auto local_noopt = [] (void* ptr) ATTRIBUTE_NOINLINE -> void* {
      |                                                           ^~~~
```

Remove the trailing return type as it is deduced from the `noopt` call anyway.
2024-10-03 08:42:56 -07:00
Aliaksei Kandratsenka
c7dcabf09a [proc_maps_iterator_test] handle unknown PT_XYZ defines 2024-10-02 18:50:24 -04:00
Aliaksei Kandratsenka
fdbf9833ab [proc_maps_iterator] add implementation on top of dl_iterate_phdr
And unbreak on it FreeBSD.

Turns out not only they don't mount procfs by default, their
/proc/pid/map fails to supply mapping offsets. Without offsets all the
hope is lost.
2024-10-02 18:07:32 -04:00
Aliaksei Kandratsenka
d882347119 [proc_maps_iterator_test] print all elf program headers
I.e. to match with what proc maps iterator did.
2024-10-02 18:06:04 -04:00
Aliaksei Kandratsenka
d20ae0c8d8 move GetProgramInvocationName into sysinfo 2024-10-02 16:52:21 -04:00
Aliaksei Kandratsenka
6fee38e5e7 build symbolizer stuff only for debug allocator
Since it is now the only place that uses it
2024-10-02 16:46:44 -04:00
Aliaksei Kandratsenka
0f8cb8416e [sampling_test] print errno when mkstemp fails
I see rare occasional failures there, which look very odd. Typically
both sampling and sampling_debug tests fail at about the same time. So
hopefully we can diagnose them sometime.
2024-10-02 16:42:32 -04:00
Aliaksei Kandratsenka
9d58d03fa4 set default cmake build type to RelWithDebInfo
Which is the only sensible default. Should have been upstream default,
really.
2024-10-02 16:42:32 -04:00
Aliaksei Kandratsenka
feb43df6ae remove some unused includes 2024-10-02 16:41:34 -04:00
Aliaksei Kandratsenka
d87c1a5c77 amputate HeapProfileTable::Snapshot
Those are remains of heap checker.
2024-10-02 16:41:34 -04:00
Aliaksei Kandratsenka
5035d10c85 drop unused kStripFrames constant 2024-10-02 16:41:28 -04:00
Aliaksei Kandratsenka
1cfbc55fbf [debugallocation_test] make death stack trace testing more rigorous
I.e. make sure we actually have stack-trace at least up to actual
allocation function, not just main().
2024-10-02 16:39:59 -04:00
Aliaksei Kandratsenka
0aa7254ac9 [debugallocation] grab entire stack trace of deletion
We used GetCallerStackTrace thingy before, but it is not entirely
reliable in it's detection of malloc stack frames (i.e. on OSX). So
lets do full thing instead. Those stacktraces are to be printed to
users anyways.
2024-10-02 16:39:59 -04:00
Andrey Semashev
28c2853cba
Avoid sampling_test failures
Increase the upper bound of allocated memory amount to avoid test failures on Kubuntu 24.04.

Fixes https://github.com/gperftools/gperftools/issues/1564.
2024-10-02 19:33:28 +03:00
Aliaksei Kandratsenka
a9a52320fc drop a bunch of unnecessary "using std::XYX" declarations 2024-09-27 22:39:39 -04:00
Aliaksei Kandratsenka
b128b1557e unbreak profiler_unittest when linking statically
When linking statically we may end up calling ProfilerGetCurrentState
earlier than profiler is initialized. And we segfaulted on that early
call. Lets make us handle this case gracefully.
2024-09-27 22:20:08 -04:00
Aliaksei Kandratsenka
f0bab33d27 do non-minimal cmake configuration for ci.yml 2024-09-27 17:46:48 -04:00
Aliaksei Kandratsenka
608e6d0625 unbreak cmake testing of heap-profiler 2024-09-27 17:34:36 -04:00
Aliaksei Kandratsenka
aaed4feb28 [heap-profiler] use regular stacktracing API
Instead of MallocHook::GetCallerStackTrace.

Thing is, GetCallerStackTrace isn't reliable beyond ELF systems, like
OSX. And, yet, things just work without it for e.g. heap
sampling. Why? Because pprof already knows how to exclude
tcmalloc-internal stack frames (by looking at e.g. tcmalloc::
namespace). So we do the same for heap profiler.

This fixes heap profiling unit tests on OSX.
2024-09-27 14:47:03 -04:00
Aliaksei Kandratsenka
c1e3eac0c6 move Invoke*Hook stuff under tcmalloc namespace
This will allow us to move heap profiling from
MallocHook::GetCallerStackTrace into plain tcmalloc::GrabBacktrace
thingy.
2024-09-27 14:46:06 -04:00
Aliaksei Kandratsenka
d0724116cf drop a bunch of bogus private stuff from public malloc_hook.h 2024-09-27 14:30:01 -04:00
Aliaksei Kandratsenka
fc86294f9d add initial github actions CI 2024-09-27 00:18:35 -04:00
Aliaksei Kandratsenka
f01510ccf2 make large_heap_fragmentation_unittest not as painful on windows 2024-09-27 00:06:13 -04:00
Aliaksei Kandratsenka
96e3eca05e amputate dead travis CI integration 2024-09-26 14:58:40 -04:00
Aliaksei Kandratsenka
ff061b4de3 actualize AUTHORS 2024-09-26 14:51:59 -04:00
Aliaksei Kandratsenka
6a7419e39f drop mmap_hook 2024-09-25 18:34:10 -04:00
Aliaksei Kandratsenka
00d235325f drop memory region map 2024-09-25 18:34:10 -04:00
Aliaksei Kandratsenka
07c30d1229 amputate mmap heap profiling
It wasn't entirely functional (i.e. see
https://github.com/gperftools/gperftools/issues/1010 or
https://github.com/gperftools/gperftools/issues/1458) and it's
underlying mmap hooks facility introduces significant source
portability complications. And since we've just dropped heap checker
we can drop entire mmap hooks stuff too.
2024-09-25 18:34:10 -04:00
Aliaksei Kandratsenka
b19a1999a4 amputate MallocHook_InitAtFirstAllocation_HeapLeakChecker logic 2024-09-25 18:34:10 -04:00
Aliaksei Kandratsenka
187b31e952 amputate heap checker 2024-09-25 18:34:09 -04:00
Aliaksei Kandratsenka
05692cc057 drop unused windows/{addr2line,nm}-pdb 2024-09-25 18:33:57 -04:00
Aliaksei Kandratsenka
be755a8d3c mass-replace NULL -> nullptr 2024-09-25 18:33:56 -04:00