-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Description
Hi,
I encountered a crash today, from the hs_err log I see the last java frame is getContextPageOffset0
.
I then used the debug jar and enabled core dump, the stack trace is bellow:
#0 0x00007fc775409387 in raise () from /lib64/libc.so.6
#1 0x00007fc77540aa78 in abort () from /lib64/libc.so.6
#2 0x00007fc776008a66 in tcmalloc::Log(tcmalloc::LogMode, char const*, int, tcmalloc::LogItem, tcmalloc::LogItem, tcmalloc::LogItem, tcmalloc::LogItem) () from /usr/lib64/libtcmalloc.so
#3 0x00007fc775ffd644 in (anonymous namespace)::InvalidFree(void*) () from /usr/lib64/libtcmalloc.so
#4 0x00007fc74eb9f701 in Contexts::getPage(int) ()
The reason is, if libtcmalloc.so.4.4.5
is PR_LOADEDed, the aligned_alloc
is from libc (because libtcmalloc.so.4.4.5 does not have aligned_alloc), while free
is from tcmalloc, then tcmalloc complains about pointer is not allocated by it.
readelf -s -W /usr/lib64/libc-2.26.so|grep aligned_alloc
1261: 000000000007f0e0 9 FUNC WEAK DEFAULT 12 aligned_alloc@@GLIBC_2.16
6011: 000000000007f0e0 9 FUNC WEAK DEFAULT 12 aligned_alloc
readelf -s -W /usr/lib64/libtcmalloc.so.4.4.5|grep aligned_alloc|wc -l
0
java-profiler/ddprof-lib/src/main/cpp/context.cpp
Lines 57 to 68 in 6fa1618
if (__atomic_load_n(&_pages[pageIndex], __ATOMIC_ACQUIRE) == NULL) { | |
u32 capacity = DD_CONTEXT_PAGE_SIZE * sizeof(Context); | |
Context *page = (Context *)aligned_alloc(sizeof(Context), capacity); | |
// need to zero the storage because there is no aligned_calloc | |
memset(page, 0, capacity); | |
if (!__sync_bool_compare_and_swap(&_pages[pageIndex], NULL, page)) { | |
free(page); | |
} else { | |
Counters::increment(CONTEXT_STORAGE_BYTES, capacity); | |
Counters::increment(CONTEXT_STORAGE_PAGES); | |
} | |
} |
Consider users are free to use any allocator, it's better not to crash. The simplest fix is to replace aligned_alloc
with malloc
.
Any thoughts ?
Thanks.
Metadata
Metadata
Assignees
Labels
No labels