-
Notifications
You must be signed in to change notification settings - Fork 946
use libmimalloc.so ,segmentfault error always occured when i free heap-data #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
i find src code in alloc. the func is mi_decl_noinline_mi_free_generic()。 |
In your project, do you use mimalloc as a malloc replacement (linked or pre loaded) or do you use the mimalloc api ? |
I USE LD_PRELOAD=libmimalloc.so to replace the malloc 。 |
if dont use mimalloc,the segmentfault will not happen |
so my code is correct |
3 similar comments
so my code is correct |
so my code is correct |
so my code is correct |
i also find if the data is freed in the same thread, the program will not crush。 |
did you try with another allocator e.g. jemalloc ? |
no , i use malloc from libc before. |
could u give me some advises to slove this problem. |
currently, i think i have not understood mimalloc enough. |
I meant using jemalloc in same way as mimalloc i.e. LD_PRELOAD=libjemalloc.so to see if your application crashes with it too. |
if my project also crashes with jemalloc, |
I would recommend you try running address sanitizer on your project. This will help eliminate if you program has an underlying memory corruption. Memory corruption can result in very different behaviour on different allocators. (That is why @devnexen is suggesting trying a different allocator.) Is your crash after a short time, or a long time. Thread start up can be a source of problems if the particular platform you are using is less tested. Have all the threads done some amount of allocation? Have they all done some deallocation? Can you share your application, or a small repro of the corruption? |
3q for ur advice,i will try to use asan to save the error log。 |
i try to use the following command to preload asan and mimalloc,it seems thar mimalloc is override by asan,so mimalloc is not working on app。 |
Did you try asan alone ? |
yeah,use asan alone is ok,but when preload asan and mimalloc together,mimalloc will not work。 |
|
sorry,i‘m afraid not,maybe i should study the source code of mimalloc |
1 similar comment
sorry,i‘m afraid not,maybe i should study the source code of mimalloc |
Hmm, that is not good -- but it seems like a double free (although in that case asan should find it but perhaps you did not recompile correctly for asan? you should not preload libasan.so).
and then run the program as is without preloading anything.
which creates
Hope we can find what is causing this. Thanks. |
thanks,if i use gcc asan,what should i do to use asan and mimalloc together correctly。 |
i get the following error log by using debug version : mimalloc: warning: mi_free: pointer might not point to a valid heap region: 0xffff34000940 Thread 23 "Other" received signal SIGABRT, Aborted. |
heap stats: peak total freed current unit count |
Usually this means that an invalid pointer is freed (usually coming from another allocator than mimalloc), but since you are overriding, this is probably a double free: freeing a pointer that was already freed before in your application. (of course, it might be a bug in mimalloc as well). One way to track this down is to run in gdb and get a stack trace at this point and see if you can figure out of the But the easiest way is probably running with the address sanitizer. Note again -- mimalloc should not be used when using the address sanitizer. We are just building with the address sanitizer to see if the bug is in your code (e.g. a double free or buffer overrun) or in mimalloc as such. The address sanitizer uses its own allocator that is build specifically to find bugs. With gcc you can build as:
see https://www.osc.edu/resources/getting_started/howto/howto_use_address_sanitizer for example. |
thanks, i will try your advice. |
in my project, i malloc many mem in different threads, but why it always crash in the same point, while it just a normal malloc. |
maybe,should i take another way to use mimalloc as using mimalloc header and allocator instead of overriding |
1 similar comment
maybe,should i take another way to use mimalloc as using mimalloc header and allocator instead of overriding |
I am going to close this issue for now; if running with the address sanitizer works correctly we can reopen this. |
i use libmimalloc.so.1.7 in a complex project with threadpool(over 20 thread),and the device is aarch64-linux-gnu, gcc is 6.2.1。
i try to use gdb to debug, the bt is '
Thread 22 "Other" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xffff51969170 (LWP 1603)]
mi_free_generic (segment=0xffff34000000, local=false, p=0xffff34000940) at mimalloc-master/src/alloc.c:440
(gdb) bt
#0 mi_free_generic (segment=0xffff34000000, local=false, p=0xffff34000940) at mimalloc-master/src/alloc.c:440
i try to print ags and local vals, as :
(gdb) p p
$1 = (void *) 0xffff34000940
(gdb) p *p
Attempt to dereference a generic pointer.
(gdb) p segment
$2 = {memid = 281471554158624, mem_is_pinned = false, mem_is_committed = false, abandoned_next = 0x21000,
next = 0x21000, prev = 0x300000000, abandoned = 0, abandoned_visits = 0, used = 0, capacity = 0, segment_size = 0,
segment_info_size = 0, cookie = 0, page_shift = 0, thread_id = 0, page_kind = MI_PAGE_SMALL, pages = {{
segment_idx = 224 '\340', segment_in_use = 1 '\001', is_reset = 1 '\001', is_committed = 1 '\001',
is_zero_init = 1 '\001', capacity = 13312, reserved = 65535, flags = {full_aligned = 0 '\000', x = {
in_full = 0 '\000', has_aligned = 0 '\000'}}, is_zero = 0 '\000', retire_expire = 0 '\000', free = 0x0,
used = 872415352, xblock_size = 65535, local_free = 0xffff34000078, xthread_free = 281471554158728,
xheap = 281471554158728, next = 0xffff34000098, prev = 0xffff34000098}}}
(gdb) p (mi_block_t)p
$3 = (mi_block_t *) 0xffff34000940
i dont know why it always trigger segmentfault, who can give me some useful info
The text was updated successfully, but these errors were encountered: