-
Notifications
You must be signed in to change notification settings - Fork 810
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
OSX debugging #50
Comments
I am actually wondering if this might be a bug in our code. |
Can't you put it in a debugger and take a look what exactly is happening? But it seems like there is memory being freed during global init (maybe because of a resize?). Interesting points would be to know what is the state of the heap at that point or right before it, what allocated that memory. I completely don't know how the override works on osx, but we had some problems like that because of the ordering of the heap initialization and overrides. |
Ah, that is no good! I am on it -- tomorrow I have access to a Mac and will look into it. For now, the message implies that a pointer is freed that perhaps was allocated using some other
Tomorrow I will also look into it, but just wanted to offer some pointers. There is also the |
MI_INTERPOSE=OFF
MI_INTERPOSE=ON
I have just pulled the following change into the branch arangodb/arangodb@6354372 Unfortunately we end up with a different error in I guess I use the overrides incorrectly.
|
Any idea why the allocations could be partially replaced? After adding an extra override for |
Great -- thanks for the debug output. I am currently working on a mac book through these problems too and addressing various issues. My feeling is indeed that the system |
I think the latest |
Thank You! Unfortunately we have still problems.
|
Good to hear there is progress -- just to confirm , the Actually, this could be related to another issue in the Apologies for your trouble, but your feedback is very helpful to get automatic overriding to work well on macOS. |
Sources upgraded maybe 3 hours ago from
Thank you for your time! |
Ah.. frustrating.. on Linux/BSD systems this is so easy with LD_PRELOAD ... :-) |
I there anything I can do? Should I try a newer version? |
Ah sorry for not following up -- I have been just a bit too busy to look into it further. However, I have been working on improving the situation of dynamic overriding on Windows which should also help on the macOS side. I will try to look into it later today or otherwise tomorrow as I do have a macbook available now for testing. |
No problem it was the same for me, I actually forgot to check the thread for some days ;) |
MacOS system libraries will call The implementation is required to check if any of the zones own a pointer. If you look at the documentation for
Basically the default malloc implementation will go through all registered malloc zones and call What I have done in my memory manager/interposer implementation to get around the most annoying performance implications of this is:
|
Why not replace the default zone, rather using interposing, like jemalloc does: https://github.com/jemalloc/jemalloc/blob/dev/src/zone.c |
Oops, I see that there is indeed a zone-based way of injecting mimalloc |
@daanx just curious to see what the status of this is. I'm having similar issues myself |
Finally I think the current version of mimalloc
this is despite it being not yet as optimal as it could be as it needs to check pointers before freeing if they belong to our zone. |
It's crashing for me when using XcodeProj |
Also, one thing to be aware of is mimalloc may need to always check that the pointer it's being given to free is one that was allocated by it, as Apple can sometimes give improper pointers to be freed |
Ah, explained much more thoroughly by Eric above 😛 |
@michaeleisel: do you mean there is crash when dynamically overriding malloc with mimalloc in XcodeProj ? Not when you create programs using mimalloc directly right? The comment by @erikolofsson is quite discouraging -- that is just terrible for allocation performance on macOS. :-( Currently, the regular |
my code works well with dynamic override on osx gives me bus error here mimalloc version: 1.6 (git master branch) same bus error occurs with or without disable build-in libc mimalloc: option 'show_errors': 1
mimalloc: option 'show_stats': 0
mimalloc: option 'eager_commit': 1
mimalloc: option 'eager_region_commit': 1
mimalloc: option 'reset_decommits': 0
mimalloc: option 'large_os_pages': 0
mimalloc: option 'reserve_huge_os_pages': 0
mimalloc: option 'segment_cache': 0
mimalloc: option 'page_reset': 1
mimalloc: option 'abandoned_page_reset': 0
mimalloc: option 'segment_reset': 0
mimalloc: option 'eager_commit_delay': 1
mimalloc: option 'reset_delay': 100
mimalloc: option 'use_numa_nodes': 0
mimalloc: option 'os_tag': 100
mimalloc: option 'max_errors': 16
[1] 3010 bus error ./cmake-build-debug/test
mimalloc: option 'show_errors': 1
mimalloc: option 'show_stats': 0
mimalloc: option 'eager_commit': 1
mimalloc: option 'eager_region_commit': 1
mimalloc: option 'reset_decommits': 0
mimalloc: option 'large_os_pages': 0
mimalloc: option 'reserve_huge_os_pages': 0
mimalloc: option 'segment_cache': 0
mimalloc: option 'page_reset': 1
mimalloc: option 'abandoned_page_reset': 0
mimalloc: option 'segment_reset': 0
mimalloc: option 'eager_commit_delay': 1
mimalloc: option 'reset_delay': 100
mimalloc: option 'use_numa_nodes': 0
mimalloc: option 'os_tag': 100
mimalloc: option 'max_errors': 16
heap stats: peak total freed unit count
reserved: 256.0 mb 256.0 mb 0 b 1 b not all freed!
committed: 967.7 kb 967.7 kb 0 b 1 b not all freed!
reset: 0 b 0 b 0 b 1 b ok
touched: 0 b 0 b 4.0 kb 1 b ok
segments: 1 1 0 not all freed!
-abandoned: 0 0 0 ok
-cached: 0 0 0 ok
pages: 15 16 1 not all freed!
-abandoned: 0 0 0 ok
-extended: 0
-noretire: 0
mmaps: 0
commits: 16
threads: 0 0 0 ok
searches: 0.0 avg
numa nodes: 1
elapsed: 0.002 s
process: user: 0.013 s, system: 0.003 s, faults: 0, reclaims: 562, rss: 1.2 mb
mimalloc: process done: 0x115827dc0
mimalloc: option 'show_errors': 1
mimalloc: option 'show_stats': 0
mimalloc: option 'eager_commit': 1
mimalloc: option 'eager_region_commit': 1
mimalloc: option 'reset_decommits': 0
mimalloc: option 'large_os_pages': 0
mimalloc: option 'reserve_huge_os_pages': 0
mimalloc: option 'segment_cache': 0
mimalloc: option 'page_reset': 1
mimalloc: option 'abandoned_page_reset': 0
mimalloc: option 'segment_reset': 0
mimalloc: option 'eager_commit_delay': 1
mimalloc: option 'reset_delay': 100
mimalloc: option 'use_numa_nodes': 0
mimalloc: option 'os_tag': 100
mimalloc: option 'max_errors': 16
heap stats: peak total freed unit count
reserved: 256.0 mb 256.0 mb 0 b 1 b not all freed!
committed: 839.2 kb 839.2 kb 0 b 1 b not all freed!
reset: 0 b 0 b 0 b 1 b ok
touched: 0 b 0 b 0 b 1 b ok
segments: 1 1 0 not all freed!
-abandoned: 0 0 0 ok
-cached: 0 0 0 ok
pages: 13 13 0 not all freed!
-abandoned: 0 0 0 ok
-extended: 0
-noretire: 0
mmaps: 0
commits: 14
threads: 0 0 0 ok
searches: 0.0 avg
numa nodes: 1
elapsed: 0.011 s
process: user: 0.016 s, system: 0.002 s, faults: 0, reclaims: 442, rss: 915.5 kb
mimalloc: process done: 0x117b39dc0 compile with AddressSanitizer, in lldb: =================================================================
==12137==ERROR: AddressSanitizer: negative-size-param: (size=-8)
#0 0x1044c8f61 in wrap___bzero (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x37f61)
#1 0x7fff38a85d6c in -[__NSArrayM insertObject:atIndex:] (CoreFoundation:x86_64h+0x1fd6c)
#2 0x7fff38a85401 in _createUniqueStringWithUTF8Bytes (CoreFoundation:x86_64h+0x1f401)
#3 0x7fff38a852f7 in parseStringTag (CoreFoundation:x86_64h+0x1f2f7)
#4 0x7fff38a8300d in parseXMLElement (CoreFoundation:x86_64h+0x1d00d)
#5 0x7fff38a83737 in parseXMLElement (CoreFoundation:x86_64h+0x1d737)
#6 0x7fff38a8310a in parseXMLElement (CoreFoundation:x86_64h+0x1d10a)
#7 0x7fff38a82186 in _CFPropertyListCreateFromUTF8Data (CoreFoundation:x86_64h+0x1c186)
#8 0x7fff38b886d8 in _CFPropertyListCreateWithData (CoreFoundation:x86_64h+0x1226d8)
#9 0x7fff38a81496 in CFPropertyListCreateWithData (CoreFoundation:x86_64h+0x1b496)
#10 0x7fff38ad21b9 in _CFCopyVersionDictionary (CoreFoundation:x86_64h+0x6c1b9)
#11 0x7fff38ad2123 in ___CFCopySystemVersionDictionary_block_invoke (CoreFoundation:x86_64h+0x6c123)
#12 0x7fff72a8b657 in _dispatch_client_callout (libdispatch.dylib:x86_64+0x2657)
#13 0x7fff72a8c7dd in _dispatch_once_callout (libdispatch.dylib:x86_64+0x37dd)
#14 0x7fff38ad20f9 in _CFCopySystemVersionDictionary (CoreFoundation:x86_64h+0x6c0f9)
#15 0x7fff38b470ba in _CFCopySystemVersionDictionaryValue (CoreFoundation:x86_64h+0xe10ba)
#16 0x7fff38b46f9b in ___CFOperatingSystemVersionGetCurrent_block_invoke (CoreFoundation:x86_64h+0xe0f9b)
#17 0x7fff72a8b657 in _dispatch_client_callout (libdispatch.dylib:x86_64+0x2657)
#18 0x7fff72a8c7dd in _dispatch_once_callout (libdispatch.dylib:x86_64+0x37dd)
#19 0x7fff38b46f7f in _CFOperatingSystemVersionGetCurrent (CoreFoundation:x86_64h+0xe0f7f)
#20 0x7fff3b1e3b21 in -[NSProcessInfo operatingSystemVersion] (Foundation:x86_64+0xc3b21)
#21 0x1136203f3 in QOperatingSystemVersion::current() (QtCore:x86_64+0x1f3f3)
#22 0x113616178 (QtCore:x86_64+0x15178)
#23 0x1000791e2 in ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) (dyld:x86_64+0x1b1e2)
#24 0x1000795ed in ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) (dyld:x86_64+0x1b5ed)
#25 0x10007400a in ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) (dyld:x86_64+0x1600a)
#26 0x100073f75 in ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) (dyld:x86_64+0x15f75)
#27 0x100073f75 in ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) (dyld:x86_64+0x15f75)
#28 0x100073f75 in ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) (dyld:x86_64+0x15f75)
#29 0x100073f75 in ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) (dyld:x86_64+0x15f75)
#30 0x100073f75 in ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) (dyld:x86_64+0x15f75)
#31 0x100072013 in ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) (dyld:x86_64+0x14013)
#32 0x1000720b3 in ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) (dyld:x86_64+0x140b3)
#33 0x1000605e5 in dyld::initializeMainExecutable() (dyld:x86_64+0x25e5)
#34 0x100065af7 in dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) (dyld:x86_64+0x7af7)
#35 0x10005f226 in dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) (dyld:x86_64+0x1226)
#36 0x10005f024 in _dyld_start (dyld:x86_64+0x1024)
Address 0x04d5194b06b8 is a wild pointer.
SUMMARY: AddressSanitizer: negative-size-param (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x37f61) in wrap___bzero
==12137==ABORTING
(lldb) AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.
Process 12137 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = Negative size used when accessing memory
frame #0: 0x00000001044df230 libclang_rt.asan_osx_dynamic.dylib`__asan::AsanDie()
libclang_rt.asan_osx_dynamic.dylib`__asan::AsanDie:
-> 0x1044df230 <+0>: pushq %rbp
0x1044df231 <+1>: movq %rsp, %rbp
0x1044df234 <+4>: pushq %rbx
0x1044df235 <+5>: pushq %rax
Target 0: (test) stopped.
(lldb) thread info -s
thread #1: tid = 0x2a4e3, 0x00000001044df230 libclang_rt.asan_osx_dynamic.dylib`__asan::AsanDie(), queue = 'com.apple.main-thread', stop reason = Negative size used when accessing memory
{
"access_size" : 0,
"access_type" : 0,
"address" : 0,
"description" : "negative-size-param",
"instrumentation_class" : "AddressSanitizer",
"pc" : 0,
"stop_type" : "fatal_error"
} |
I am also getting the following errors. Is it safe to say that the static object implementation doesn't work for OSX @daanx ?
|
The problem does not occur on linux.
https://github.com/microsoft/mimalloc/blob/master/src/alloc.c#L212
In order to reproduce you could build the tests in this branch:
https://github.com/arangodb/arangodb/tree/feature/mimalloc
The text was updated successfully, but these errors were encountered: