Commit Graph

179 Commits

Author SHA1 Message Date
Aliaksey Kandratsenka
3b12487a83 gtestify memalign_unittest 2024-02-27 17:00:42 -05:00
Aliaksey Kandratsenka
9cb7f7040e gtestify frag_unittest 2024-02-27 17:00:35 -05:00
Aliaksey Kandratsenka
5fabaea30d link page_heap_test with entirety of tcmalloc_minimal
This makes page_heap_test a bit more uniform with rest of things and
prevents any future missing symbols issues.
2024-02-27 17:00:35 -05:00
Aliaksey Kandratsenka
2940450c7a gtestify profiledata_unittest 2024-02-27 16:50:07 -05:00
Aliaksey Kandratsenka
bbae941492 gtestify profile-handler_unittest 2024-02-27 16:50:07 -05:00
Aliaksey Kandratsenka
f8da159013 add function_ref_test 2024-02-21 21:57:37 -05:00
Aliaksey Kandratsenka
bfbfa333eb add cleanup_test
This also let us spot and fix missing include in the header.
2024-02-21 21:37:47 -05:00
Aliaksey Kandratsenka
61b1e05848 unbreak make dist
In 57d6ecc4ae I removed obsolete
src/windows/TODO but failed to remove it from Makefile.am

I also previously failed to arrange distribution of vendored
googletest. And we also failed to distribute headers in src/tests/

This is all fixed now.
2024-02-21 13:44:17 -05:00
Aliaksey Kandratsenka
0906dacc48 gtestify more tests
Those are malloc_hook_test, mmap_hook_test, page_heap_test,
sampler_test, stack_trace_table_test.
2024-02-20 14:34:28 -05:00
Aliaksey Kandratsenka
bfa30bf7df gtestify 3 simpler tests
Those are packed-cache_test, pagemap_unittest, safe_strerror_test
2024-02-20 14:34:23 -05:00
Aliaksey Kandratsenka
ff2dce5e67 gtestify addressmap_unittest 2024-02-20 14:34:23 -05:00
Aliaksey Kandratsenka
c1799405ae gtestify check_address_test 2024-02-20 14:34:23 -05:00
Aliaksey Kandratsenka
a46a391b14 gtestify low_level_alloc_unittest 2024-02-20 14:34:20 -05:00
Aliaksey Kandratsenka
6c24a59682 introduce vendor copy of googletest 2024-02-20 14:30:24 -05:00
Aliaksey Kandratsenka
8318e08962 fix missing AM_CXXFLAGS introduced in recent automake refactoring 2024-02-20 12:06:30 -05:00
Aliaksey Kandratsenka
3a2a7e05f6 add missing internal_logging.cc to packed_cache_test
It wasn't caught before because when optimization is enabled ASSERT-s
inside packed-cache-inl get optimized away (because checks are
tautological).
2024-02-17 18:03:41 -05:00
Aliaksey Kandratsenka
8a147b4833 untangle a number of unittests from libtcmalloc_minimal.so 2024-02-07 23:54:03 -05:00
Aliaksey Kandratsenka
b0e2928343 mingw: don't add patch_functions.cc in libcommon.la 2024-02-07 20:30:53 -05:00
Aliaksey Kandratsenka
7756b4cc61 don't force TMPDIR on all unittests
Turns out at least on FreeBSD tmpfile will fail if TMPDIR points to
non-existant directory. This also has nice property of leaving it down
to users to set up TMPDIR the way they want.
2024-02-07 19:35:37 -05:00
Aliaksey Kandratsenka
c52c321bdd replace raw printer with usage of generic writer facility 2024-02-07 15:46:54 -05:00
Aliaksey Kandratsenka
59f0247033 liberate sampler_test from linking to libtcmalloc
This test is exercising purely sampling interval logic.
2024-02-07 15:45:25 -05:00
Aliaksey Kandratsenka
a02ac30bbf rework and optimize structure of Makefile.am
There were far too many intermediate libraries, references to obsolete
libtool bugs and whatnot.

We now have libcommon.la as a convenience archive that contains
spinlock, logging and misc stuff. A number of unit tests that need
those facilities are being linked to this.

Then we have libstacktrace.la convenience archive, since it is used by
libtcmalloc.la and libprofiler.la.

And after that we're simply directly creating our main library
products: libtcmalloc_minimal{,_debug}.la, libtcmalloc_{,debug}.la,
libprofiler.la etc.
2024-02-07 15:45:22 -05:00
Aliaksey Kandratsenka
771a01ed28 rework and simplify emergency malloc integration
We now wrap StackTraceScope thingy in tcmalloc-specific parts, instead
of automagically inside every stacktrace.cc function. TCMalloc bits
all need to grab stacktraces via newly introduced
tcmalloc::GrabBacktrace (which handles emergency malloc wrapping).

New approach eliminates the need for doing fake stacktrace scope. CPU
profiler, being distinct .so library couldn't take advantage of
emergency malloc anyways.

This simplifies the build further and eliminates another potential
point of runtime divergence when stacktrace is linked to both
libprofiler and libtcmalloc.
2024-02-05 14:27:02 -05:00
Aliaksey Kandratsenka
4be76ab707 drop symbols weakening step
It has questionable value and most importantly, it was broken lots of
years without anyone complaining. So lets get things simpler.
2024-02-05 00:00:00 -05:00
Aliaksey Kandratsenka
ca50448a1e drop export-symbols-regex stuff for libstacktrace.la
It has no effect, because libstacktrace.la is convenience archive, not
a library we install.
2024-02-04 23:56:08 -05:00
Aliaksey Kandratsenka
ba3d790855 drop running pprof -test as part of make check
Not needed anymore.
2024-02-04 23:46:39 -05:00
Aliaksey Kandratsenka
144c118f92 drop outdated comment in Makefile.am 2024-02-04 23:42:58 -05:00
Aliaksey Kandratsenka
e262ebc741 ship everything under vsprojects/ in make dist
We also drop all those WINDOWS_PROJECTS amends and simplify makefile.
2024-02-04 23:38:18 -05:00
Aliaksey Kandratsenka
b49920ea64 don't bother listing every header in Makefile.am
For compiling things automake never needs to be given a full set of
headers. Usually headers are specified so that make dist includes them
into archive, but we can achieve this goal easier.

This reduces size and complexity of our Makefile.am stuff.
2024-02-04 23:20:35 -05:00
Aliaksey Kandratsenka
1331c0e0d1 drop long deprecated google/ headers 2024-02-04 21:54:46 -05:00
Aliaksey Kandratsenka
2e5ecb4de6 amputate src/base/simple_mutex.h
Use standard mutex instead
2024-02-04 16:38:21 -05:00
Aliaksey Kandratsenka
21e66f807c enable -Wthread-safety for clang 2024-02-04 13:37:53 -05:00
Aliaksey Kandratsenka
6691226953 split and rewrite TLS access for thread caches
Logic was removed from thread_cache.{h,cc} into
thread_cache_ptr.{h,cc}.

Separation will help possible future evolution, and we already changed
the logic quite a bit:

* early access (when TLS isn't initialized yet) now uses global
ThreadCache instance. We therefore have ThreadCachePtr instances
managing required locking. This eliminates unnecessary complication of
PTHREADS_CRASHES_IF_RUN_TOO_EARLY logic, and any other danger of
touching TLS too early. BTW previous implementation actually leaked
initial early-initialized ThreadCache instance(!)

* old configure-time HAVE_TLS logic is amputated. Config-time part of
it made little sense as C++ 17 guarantees availability of
thread_local, but we have manually curated deny-list of "bad" OSes,
that we tested (via compile checks!) at configure time. Now this
is all compile time. There is now compile-time kHaveGoodTLS variable
and we're using it mostly via if constexpr.

* kHaveGoodTLS case of creating thread cache is simplified and made
more straightforward (no need to have in_setspecific logic).

* !kHaveGoodTLS case if fixed and improved too. We avoid
std:🧵:get_id, as it deadlocks on mingw. We use errno address as
a portable and (usually) async-signal safe 'my thread' identifier. We
also eliminate linear searching of thread's cache and replace it with
straightforward hash table lookup.
2024-02-03 15:57:14 -05:00
Aliaksey Kandratsenka
51d3340b39 avoid -Wunused-results warnings from read/write
glibc with _FORTIFY_SOURCE sets those up to give warnings on unused
results. We used to disable this warning globally, but lets do better.
2024-01-30 17:08:29 -05:00
Aliaksey Kandratsenka
82a36a6fcd bump required c++ standard to c++-17 2024-01-30 15:54:24 -05:00
Aliaksey Kandratsenka
5db2adc4e7 drop stale workaround for ancient solaris issue 2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka
a3080fa8d6 extract proc-maps iteration into own file and cover it by tests
This allows us, later, to avoid building this stuff in configurations
that don't use it. I have also reduced API and ABI surface to enable
further refactorings.
2024-01-29 21:02:17 -05:00
Aliaksey Kandratsenka
3e328e4058 unbreak make dist 2024-01-29 20:16:39 -05:00
lennoxho
9a6848de8a A number of cleanups
* Remove build dependency on HAVE_PTHREAD
* Remove build dependency on HAVE_STD_ALIGNED_VAL_T and ENABLE_ALIGNED_NEW_DELETE
* Remove redundant tcmalloc.h files & ensure there are no cross-build-tool references
* Adopt automake commit 26927d1 in the CMake build
2024-01-29 17:15:53 -08:00
lennoxho
96f34120fe Several build fixes and cleanups
- Fix CMake builds for MinGW and MSVC
- Ensure the Autotools, CMake and VSProj builds do not reference each others' config.h
- Use std:🧵:id instead of our own thread ID wrappers
- Moved explicit TLS wrapper functions into the tcmalloc:: namespace and change their visibility to hidden
Resolves #1486
2024-01-26 16:56:17 -05:00
lennoxho
5cab8f3f77 Convert MinGW builds to always use WinAPI based threading facilities. See ##1483 2024-01-24 21:47:06 -05:00
Aliaksey Kandratsenka
24774ebb38 introduce generic_writer facility 2024-01-24 17:30:18 -05:00
Aliaksey Kandratsenka
5abc572130 move dynamic_annotations.cc under libsysinfo.la
See github issue #1474 for immediate reason.

Note, this entire idea of number of convenience libraries is likely
simply artifact of Google's codebase past. We don't really need this
complexity. But I am holding big reorganization of this for after API
and ABI work. For now, simply moving dynamic_annotations.cc into
libsysinfo fixes things. Most of the code links both anyways. So lets
just do it.
2024-01-04 19:35:47 -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
Mateusz Jakub Fila
b8e75ae6fe Add mallinfo2 function 2023-12-07 14:10:51 +01:00
Aliaksey Kandratsenka
4d1a9e9226 stacktrace_unittest: test all stacktrace capturing methods 2023-10-27 19:06:15 -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
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
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