facebook/folly

link static to jemalloc or tcmalloc will cause coredump

Closed this issue · 3 comments

as title, if link with jemalloc or tcmalloc static will coredump, but link dynamic works well? can guy's fix this problem

bt:

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bazel-bin/src/test/test...
[New LWP 292737]

warning: Section `.reg-xstate/292737' in core file too small.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./bazel-bin/src/test/test'.
Program terminated with signal SIGSEGV, Segmentation fault.

warning: Section `.reg-xstate/292737' in core file too small.
#0  atomic_load_p (mo=atomic_memory_order_relaxed, a=<optimized out>) at include/jemalloc/internal/atomic.h:85
85      include/jemalloc/internal/atomic.h: No such file or directory.
(gdb) bt
#0  atomic_load_p (mo=atomic_memory_order_relaxed, a=<optimized out>) at include/jemalloc/internal/atomic.h:85
#1  rtree_leaf_elm_bits_read (dependent=true, elm=<optimized out>, rtree=<optimized out>, tsdn=0x7fac3e216980) at include/jemalloc/internal/rtree.h:185
#2  rtree_leaf_elm_read (dependent=true, elm=<optimized out>, rtree=<optimized out>, tsdn=0x7fac3e216980) at include/jemalloc/internal/rtree.h:247
#3  emap_edata_lookup_batch (result=result@entry=0x318, metadata_visitor_ctx=<synthetic pointer>, metadata_visitor=<optimized out>, ptr_getter_ctx=ptr_getter_ctx@entry=0x7ffc1e96c9f0,
    ptr_getter=<optimized out>, nptrs=<optimized out>, emap=<optimized out>, tsd=tsd@entry=0x7fac3e216980) at include/jemalloc/internal/emap.h:342
#4  tcache_bin_flush_edatas_lookup (tsd=tsd@entry=0x7fac3e540770, arr=arr@entry=0x7ffc1e96cf40, nflush=<optimized out>, edatas=edatas@entry=0x7ffc1e96cb50, binind=2) at src/tcache.c:306
#5  0x000055d441fad485 in tcache_bin_flush_impl_small (nflush=<optimized out>, ptrs=0x7ffc1e96cf40, binind=<optimized out>, cache_bin=<optimized out>, tcache=<optimized out>, tsd=0x7fac3e540770)
    at src/tcache.c:335
#6  tcache_bin_flush_impl (small=true, nflush=<optimized out>, ptrs=0x7ffc1e96cf40, binind=<optimized out>, cache_bin=<optimized out>, tcache=<optimized out>, tsd=0x7fac3e540770) at src/tcache.c:725
#7  tcache_bin_flush_bottom (small=true, rem=<optimized out>, binind=<optimized out>, cache_bin=<optimized out>, tcache=<optimized out>, tsd=0x7fac3e540770) at src/tcache.c:760
#8  je_tcache_bin_flush_small (tsd=tsd@entry=0x7fac3e540770, tcache=<optimized out>, cache_bin=<optimized out>, binind=<optimized out>, rem=<optimized out>) at src/tcache.c:769
#9  0x000055d441f3bc2d in tcache_dalloc_small (slow_path=true, binind=<optimized out>, ptr=0x55d442386650, tcache=<optimized out>, tsd=0x7fac3e540770) at include/jemalloc/internal/tcache_inlines.h:205
#10 arena_sdalloc (slow_path=<optimized out>, caller_alloc_ctx=<optimized out>, tcache=<optimized out>, size=<optimized out>, ptr=<optimized out>, tsdn=<optimized out>)
    at include/jemalloc/internal/arena_inlines_b.h:496
#11 isdalloct (slow_path=<optimized out>, alloc_ctx=<optimized out>, tcache=<optimized out>, size=<optimized out>, ptr=<optimized out>, tsdn=<optimized out>)
    at include/jemalloc/internal/jemalloc_internal_inlines_c.h:171
#12 isfree (slow_path=<optimized out>, tcache=<optimized out>, usize=<optimized out>, ptr=<optimized out>, tsd=<optimized out>) at src/jemalloc.c:3002
#13 je_sdallocx_default (ptr=0x55d442386650, size=<optimized out>, flags=<optimized out>) at src/jemalloc.c:3889
#14 0x000055d441decb2a in __gnu_cxx::new_allocator<char>::deallocate (__t=<optimized out>, __p=<optimized out>, this=0x7ffc1e96d170) at /usr/include/c++/11/ext/new_allocator.h:145
#15 std::allocator_traits<std::allocator<char> >::deallocate (__n=<optimized out>, __p=<optimized out>, __a=...) at /usr/include/c++/11/bits/alloc_traits.h:496
#16 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_destroy (__size=<optimized out>, this=0x7ffc1e96d170) at /usr/include/c++/11/bits/basic_string.h:245
#17 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose (this=0x7ffc1e96d170) at /usr/include/c++/11/bits/basic_string.h:240
#18 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string (this=0x7ffc1e96d170, __in_chrg=<optimized out>) at /usr/include/c++/11/bits/basic_string.h:672
#19 folly::CacheLocality::readFromProcCpuinfo () at external/folly/folly/concurrency/CacheLocality.cpp:293
#20 0x000055d441dece95 in folly::getSystemLocalityInfo () at external/folly/folly/concurrency/CacheLocality.cpp:48
#21 folly::CacheLocality::system<std::atomic> () at external/folly/folly/concurrency/CacheLocality.cpp:45
#22 0x000055d441debb4c in folly::detail::AccessSpreaderBase::initialize (state=...,
    pickGetcpuFunc=@0x55d441db9b70: {folly::Getcpu::Func (void)} 0x55d441db9b70 <folly::AccessSpreader<std::atomic>::pickGetcpuFunc()>,
    system=@0x55d441dece50: {const folly::CacheLocality &(void)} 0x55d441dece50 <folly::CacheLocality::system<std::atomic>()>) at external/folly/folly/concurrency/CacheLocality.cpp:374
#23 0x000055d441ded47e in folly::AccessSpreader<std::atomic>::initialize (state=...) at external/folly/folly/concurrency/CacheLocality.h:371
#24 folly::AccessSpreader<std::atomic>::state () at external/folly/folly/concurrency/CacheLocality.h:261
#25 folly::AccessSpreader<std::atomic>::state () at external/folly/folly/concurrency/CacheLocality.h:258
#26 folly::detail::AccessSpreaderStaticInit::AccessSpreaderStaticInit (this=0x55d441b6a000) at external/folly/folly/concurrency/CacheLocality.cpp:364
#27 __static_initialization_and_destruction_0 (__priority=65535, __initialize_p=1) at external/folly/folly/concurrency/CacheLocality.cpp:366
#28 _GLOBAL__sub_I__ZN5folly13CacheLocality6systemISt6atomicEERKS0_v () at external/folly/folly/concurrency/CacheLocality.cpp:606
#29 0x00007fac3e58eebb in call_init (env=<optimized out>, argv=0x7ffc1e96f4e8, argc=1) at ../csu/libc-start.c:145
#30 __libc_start_main_impl (main=0x55d441c6bc40 <main(int, char**)>, argc=1, argv=0x7ffc1e96f4e8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffc1e96f4d8)
    at ../csu/libc-start.c:379
#31 0x000055d441c6bac5 in _start ()
(gdb)

#2271 I give mistake info , link gperftools and www.github.com/google/tcmalloc static all will coredump, anyway, gperftools not support nallocx, so will coredump at goodMallocSize, but coredump mentioned at this issue caused for unknown reason, I guess maybe releated with folly/memory/detail/MallocImpl.h void* mallocx(size_t, int) attribute((nothrow, weak));

@yfeldblum can U CC?

it turns out caused by libaio