Giter Club home page Giter Club logo

Comments (25)

erikolofsson avatar erikolofsson commented on July 19, 2024 3

MacOS system libraries will call free on any pointer, it doesn't even have to be previously allocated. I have seen system library code (I believe it was ObjC, or swift runtime) where it stores either an allocated pointer, or a pointer to constant data and then calls free on it, letting the memory allocators figure out if it's owned or not.

The implementation is required to check if any of the zones own a pointer. If you look at the documentation for _malloc_zone_t.

size_t (* MALLOC_ZONE_FN_PTR(size))(struct _malloc_zone_t *zone, const void *ptr); /* returns the size of a block or 0 if not in this zone; must be fast, especially for negative answers */

Basically the default malloc implementation will go through all registered malloc zones and call size(zone, ptr) until it finds a zone that claims ownership of that pointer and then call free on that zone.

What I have done in my memory manager/interposer implementation to get around the most annoying performance implications of this is:

  • Interpose the whole machinery of malloc zones
  • If no other zones are registered, just call my free implementation
  • Opportunistically check if the zone was created by me. This is just aligning the pointer and checking a magic number in header. This involves _setjmp and catching segfaults if the checked location is not a valid pointer
  • Lastly fall back to zones that are registered, but not created by me. This uses the same method of going through all zones and calling size()

from mimalloc.

daanx avatar daanx commented on July 19, 2024 2

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.

from mimalloc.

daanx avatar daanx commented on July 19, 2024 1

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 malloc? The _ZdlPv routine is plain delete on a C++ object. (One thing it could be is that the overriding is kicking in too late where an object is allocated using the system malloc, and then freed by mimalloc.)

  • Can you compile the debug version with cmake ../.. -DMI_CHECK_FULL=ON to enable all assertions?

  • By default, the macOS version uses "interpose" but only overrides the four basic functions, malloc, free, realloc and calloc -- I wonder if we need to interpose more functions, like the array new or something.

  • By running cmake as cmake ../.. -DMI_CHECK_FULL=ON -DMI_INTERPOSE=OFF we use malloc zones instead of interpose --maybe that will work? This is still more experimental though.

Tomorrow I will also look into it, but just wanted to offer some pointers. There is also the MI_TLS_RECURSE_GUARD that is enabled when MI_INTERPOSE is enabled which prevents recursion as the dylib loader in macOS tries to allocate memory itself (with mimalloc) for thread local storage while the mimalloc module is still being loaded ... :(

from mimalloc.

daanx avatar daanx commented on July 19, 2024 1

Ah.. frustrating.. on Linux/BSD systems this is so easy with LD_PRELOAD ... :-)
Anyway, I will keep working on this -- I have the macOS machine available maybe tomorrow but otherwise next week. Apologies for your troubles getting the overriding to work for you.

from mimalloc.

ObiWahn avatar ObiWahn commented on July 19, 2024

I am actually wondering if this might be a bug in our code.

from mimalloc.

santagada avatar santagada commented on July 19, 2024

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.

from mimalloc.

ObiWahn avatar ObiWahn commented on July 19, 2024

MI_INTERPOSE=OFF

cupertino:arangodb-build jenkins$ MIMALLOC_VERBOSE=1 ./bin/arangodbtests --gtest_filter=SimpleHttpClientCommunicatorTest.requests_are_properly_aborted
mimalloc: process init: 0x7fffc980c3c0
mimalloc: debug level : 3
mimalloc: option 'secure': 0
mimalloc: option 'pool_commit': 0
mimalloc: option 'page_reset': 0
mimalloc: option 'cache_reset': 0
Note: Google Test filter = SimpleHttpClientCommunicatorTest.requests_are_properly_aborted
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from SimpleHttpClientCommunicatorTest
[ RUN      ] SimpleHttpClientCommunicatorTest.requests_are_properly_aborted
mimalloc: option 'show_errors': 3
mimalloc: error: trying to mi_free a pointer that does not point to a valid heap space: 0x7fd1b551e6f0
mimalloc: assertion failed: at "/Users/jenkins/arangodb/3rdParty/mimalloc/src/options.c":121, _mi_error_message
  assertion: "false"
Abort trap: 6 (core dumped)

MI_INTERPOSE=ON

cupertino:arangodb-build jenkins$ MIMALLOC_VERBOSE=1 ./bin/arangodbtests --gtest_filter=SimpleHttpClientCommunicatorTest.requests_are_properly_aborted
mimalloc: option 'secure': 0
mimalloc: option 'pool_commit': 0
mimalloc: assertion failed: at "/Users/jenkins/arangodb/3rdParty/mimalloc/src/page.c":101, _mi_page_is_valid
  assertion: "segment->thread_id == page->heap->thread_id"
Abort trap: 6 (core dumped)

I have just pulled the following change into the branch

arangodb/arangodb@6354372
That seems to resolve the problem here (The test fixture is using a builder in the constructor). It was made because we had issues with thread_local variables on windows.


Unfortunately we end up with a different error in curl (https://github.com/arangodb/arangodb/blob/devel/3rdParty/curl/curl-7.63.0/lib/url.c#L2708-L2761).

I guess I use the overrides incorrectly. strdup is used in one of your test - So it should work. I think it is
rather strange that within the same TU some of the functions get substituted while others seem to stay the same.
UPDATE -- running your static tests that use strdup on the same machine works fine.

Process 97510 stopped                                        
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x0000000107219ad2 arangodbtests`create_conn_helper_init_proxy(conn=0x00000001109a8800) at url.c:2708
   2705    * Detect what (if any) proxy to use
   2706    *************************************************************/
   2707   if(data->set.str[STRING_PROXY]) {                                      
-> 2708     proxy = strdup(data->set.str[STRING_PROXY]);          
   2709     /* if global proxy is set, this is it */                             
   2710     if(NULL == proxy) {                               
   2711       failf(data, "memory shortage");                                    
Target 0: (arangodbtests) stopped.                            
(lldb) si                                                                        
Process 97510 stopped                                         
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0984919 libsystem_c.dylib`strdup
libsystem_c.dylib`strdup:                                                        
->  0x7fffc0984919 <+0>: pushq  %rbp                          
    0x7fffc098491a <+1>: movq   %rsp, %rbp                                       
    0x7fffc098491d <+4>: pushq  %r15
    0x7fffc098491f <+6>: pushq  %r14
Target 0: (arangodbtests) stopped.
(lldb) s
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc098491a libsystem_c.dylib`strdup + 1
libsystem_c.dylib`strdup:
->  0x7fffc098491a <+1>: movq   %rsp, %rbp
    0x7fffc098491d <+4>: pushq  %r15
    0x7fffc098491f <+6>: pushq  %r14
    0x7fffc0984921 <+8>: pushq  %rbx
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc098491d libsystem_c.dylib`strdup + 4
libsystem_c.dylib`strdup:
->  0x7fffc098491d <+4>: pushq  %r15
    0x7fffc098491f <+6>: pushq  %r14
    0x7fffc0984921 <+8>: pushq  %rbx
    0x7fffc0984922 <+9>: pushq  %rax
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc098491f libsystem_c.dylib`strdup + 6
libsystem_c.dylib`strdup:
->  0x7fffc098491f <+6>:  pushq  %r14
    0x7fffc0984921 <+8>:  pushq  %rbx
    0x7fffc0984922 <+9>:  pushq  %rax
    0x7fffc0984923 <+10>: movq   %rdi, %r14
Target 0: (arangodbtests) stopped.
(lldb) s
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0984921 libsystem_c.dylib`strdup + 8
libsystem_c.dylib`strdup:
->  0x7fffc0984921 <+8>:  pushq  %rbx
    0x7fffc0984922 <+9>:  pushq  %rax
    0x7fffc0984923 <+10>: movq   %rdi, %r14
    0x7fffc0984926 <+13>: callq  0x7fffc0929b40            ; strlen
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped                                                                                                                                                                                                                                                [210/11845]
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0984922 libsystem_c.dylib`strdup + 9
libsystem_c.dylib`strdup:
->  0x7fffc0984922 <+9>:  pushq  %rax
    0x7fffc0984923 <+10>: movq   %rdi, %r14
    0x7fffc0984926 <+13>: callq  0x7fffc0929b40            ; strlen
    0x7fffc098492b <+18>: movq   %rax, %rbx
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0984923 libsystem_c.dylib`strdup + 10
libsystem_c.dylib`strdup:
->  0x7fffc0984923 <+10>: movq   %rdi, %r14
    0x7fffc0984926 <+13>: callq  0x7fffc0929b40            ; strlen
    0x7fffc098492b <+18>: movq   %rax, %rbx
    0x7fffc098492e <+21>: incq   %rbx
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0984926 libsystem_c.dylib`strdup + 13
libsystem_c.dylib`strdup:
->  0x7fffc0984926 <+13>: callq  0x7fffc0929b40            ; strlen
    0x7fffc098492b <+18>: movq   %rax, %rbx
    0x7fffc098492e <+21>: incq   %rbx
    0x7fffc0984931 <+24>: movq   %rbx, %rdi
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b40 libsystem_c.dylib`strlen
libsystem_c.dylib`strlen:
->  0x7fffc0929b40 <+0>: pushq  %rbp
    0x7fffc0929b41 <+1>: movq   %rsp, %rbp
    0x7fffc0929b44 <+4>: movq   %rdi, %rcx
    0x7fffc0929b47 <+7>: movq   %rdi, %rdx
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b41 libsystem_c.dylib`strlen + 1
libsystem_c.dylib`strlen:
->  0x7fffc0929b41 <+1>:  movq   %rsp, %rbp
    0x7fffc0929b44 <+4>:  movq   %rdi, %rcx
    0x7fffc0929b47 <+7>:  movq   %rdi, %rdx
    0x7fffc0929b4a <+10>: andq   $-0x10, %rdi
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b44 libsystem_c.dylib`strlen + 4
libsystem_c.dylib`strlen:
->  0x7fffc0929b44 <+4>:  movq   %rdi, %rcx
    0x7fffc0929b47 <+7>:  movq   %rdi, %rdx
    0x7fffc0929b4a <+10>: andq   $-0x10, %rdi
    0x7fffc0929b4e <+14>: pxor   %xmm0, %xmm0
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped                                                                                                                                                                                                                                                [150/11845]
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b47 libsystem_c.dylib`strlen + 7
libsystem_c.dylib`strlen:
->  0x7fffc0929b47 <+7>:  movq   %rdi, %rdx
    0x7fffc0929b4a <+10>: andq   $-0x10, %rdi
    0x7fffc0929b4e <+14>: pxor   %xmm0, %xmm0
    0x7fffc0929b52 <+18>: pcmpeqb (%rdi), %xmm0
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b4a libsystem_c.dylib`strlen + 10
libsystem_c.dylib`strlen:
->  0x7fffc0929b4a <+10>: andq   $-0x10, %rdi
    0x7fffc0929b4e <+14>: pxor   %xmm0, %xmm0
    0x7fffc0929b52 <+18>: pcmpeqb (%rdi), %xmm0
    0x7fffc0929b56 <+22>: pmovmskb %xmm0, %esi
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b4e libsystem_c.dylib`strlen + 14
libsystem_c.dylib`strlen:
->  0x7fffc0929b4e <+14>: pxor   %xmm0, %xmm0
    0x7fffc0929b52 <+18>: pcmpeqb (%rdi), %xmm0
    0x7fffc0929b56 <+22>: pmovmskb %xmm0, %esi
    0x7fffc0929b5a <+26>: andq   $0xf, %rcx
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b52 libsystem_c.dylib`strlen + 18
libsystem_c.dylib`strlen:
->  0x7fffc0929b52 <+18>: pcmpeqb (%rdi), %xmm0
    0x7fffc0929b56 <+22>: pmovmskb %xmm0, %esi
    0x7fffc0929b5a <+26>: andq   $0xf, %rcx
    0x7fffc0929b5e <+30>: orq    $-0x1, %rax
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b56 libsystem_c.dylib`strlen + 22
libsystem_c.dylib`strlen:
->  0x7fffc0929b56 <+22>: pmovmskb %xmm0, %esi
    0x7fffc0929b5a <+26>: andq   $0xf, %rcx
    0x7fffc0929b5e <+30>: orq    $-0x1, %rax
    0x7fffc0929b62 <+34>: shlq   %cl, %rax
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b5a libsystem_c.dylib`strlen + 26
libsystem_c.dylib`strlen:
->  0x7fffc0929b5a <+26>: andq   $0xf, %rcx
    0x7fffc0929b5e <+30>: orq    $-0x1, %rax
    0x7fffc0929b62 <+34>: shlq   %cl, %rax
    0x7fffc0929b65 <+37>: andl   %eax, %esi
Target 0: (arangodbtests) stopped.
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b5e libsystem_c.dylib`strlen + 30
libsystem_c.dylib`strlen:
->  0x7fffc0929b5e <+30>: orq    $-0x1, %rax
    0x7fffc0929b62 <+34>: shlq   %cl, %rax
    0x7fffc0929b65 <+37>: andl   %eax, %esi
    0x7fffc0929b67 <+39>: je     0x7fffc0929b80            ; <+64>
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b62 libsystem_c.dylib`strlen + 34
libsystem_c.dylib`strlen:
->  0x7fffc0929b62 <+34>: shlq   %cl, %rax
    0x7fffc0929b65 <+37>: andl   %eax, %esi
    0x7fffc0929b67 <+39>: je     0x7fffc0929b80            ; <+64>
    0x7fffc0929b69 <+41>: bsfl   %esi, %eax
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b65 libsystem_c.dylib`strlen + 37
libsystem_c.dylib`strlen:
->  0x7fffc0929b65 <+37>: andl   %eax, %esi
    0x7fffc0929b67 <+39>: je     0x7fffc0929b80            ; <+64>
    0x7fffc0929b69 <+41>: bsfl   %esi, %eax
    0x7fffc0929b6c <+44>: subq   %rdx, %rdi
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b67 libsystem_c.dylib`strlen + 39
libsystem_c.dylib`strlen:
->  0x7fffc0929b67 <+39>: je     0x7fffc0929b80            ; <+64>
    0x7fffc0929b69 <+41>: bsfl   %esi, %eax
    0x7fffc0929b6c <+44>: subq   %rdx, %rdi
    0x7fffc0929b6f <+47>: addq   %rdi, %rax
Target 0: (arangodbtests) stopped.
(lldb) s
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b69 libsystem_c.dylib`strlen + 41
libsystem_c.dylib`strlen:
->  0x7fffc0929b69 <+41>: bsfl   %esi, %eax
    0x7fffc0929b6c <+44>: subq   %rdx, %rdi
    0x7fffc0929b6f <+47>: addq   %rdi, %rax
    0x7fffc0929b72 <+50>: popq   %rbp
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b6c libsystem_c.dylib`strlen + 44
libsystem_c.dylib`strlen:
->  0x7fffc0929b6c <+44>: subq   %rdx, %rdi
    0x7fffc0929b6f <+47>: addq   %rdi, %rax
    0x7fffc0929b72 <+50>: popq   %rbp
    0x7fffc0929b73 <+51>: retq
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b6f libsystem_c.dylib`strlen + 47
libsystem_c.dylib`strlen:
->  0x7fffc0929b6f <+47>: addq   %rdi, %rax
    0x7fffc0929b72 <+50>: popq   %rbp
    0x7fffc0929b73 <+51>: retq
    0x7fffc0929b74 <+52>: nopw   %cs:(%rax,%rax)
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b72 libsystem_c.dylib`strlen + 50
libsystem_c.dylib`strlen:
->  0x7fffc0929b72 <+50>: popq   %rbp
    0x7fffc0929b73 <+51>: retq
    0x7fffc0929b74 <+52>: nopw   %cs:(%rax,%rax)
    0x7fffc0929b80 <+64>: addq   $0x10, %rdi
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0929b73 libsystem_c.dylib`strlen + 51
libsystem_c.dylib`strlen:
->  0x7fffc0929b73 <+51>: retq
    0x7fffc0929b74 <+52>: nopw   %cs:(%rax,%rax)
    0x7fffc0929b80 <+64>: addq   $0x10, %rdi
    0x7fffc0929b84 <+68>: pxor   %xmm0, %xmm0
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc098492b libsystem_c.dylib`strdup + 18
libsystem_c.dylib`strdup:
->  0x7fffc098492b <+18>: movq   %rax, %rbx
    0x7fffc098492e <+21>: incq   %rbx
    0x7fffc0984931 <+24>: movq   %rbx, %rdi
    0x7fffc0984934 <+27>: callq  0x7fffc09ae87a            ; symbol stub for: malloc
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc098492e libsystem_c.dylib`strdup + 21
libsystem_c.dylib`strdup:
->  0x7fffc098492e <+21>: incq   %rbx
    0x7fffc0984931 <+24>: movq   %rbx, %rdi
    0x7fffc0984934 <+27>: callq  0x7fffc09ae87a            ; symbol stub for: malloc
    0x7fffc0984939 <+32>: movq   %rax, %r15
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0984931 libsystem_c.dylib`strdup + 24
libsystem_c.dylib`strdup:
->  0x7fffc0984931 <+24>: movq   %rbx, %rdi
    0x7fffc0984934 <+27>: callq  0x7fffc09ae87a            ; symbol stub for: malloc
    0x7fffc0984939 <+32>: movq   %rax, %r15
    0x7fffc098493c <+35>: xorl   %eax, %eax
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0984934 libsystem_c.dylib`strdup + 27
libsystem_c.dylib`strdup:
->  0x7fffc0984934 <+27>: callq  0x7fffc09ae87a            ; symbol stub for: malloc
    0x7fffc0984939 <+32>: movq   %rax, %r15
    0x7fffc098493c <+35>: xorl   %eax, %eax
    0x7fffc098493e <+37>: testq  %r15, %r15
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc09ae87a libsystem_c.dylib`malloc
libsystem_c.dylib`malloc:
->  0x7fffc09ae87a <+0>: jmpq   *0x8e3dd10(%rip)          ; (void *)0x00007fffc0a741e8: malloc

libsystem_c.dylib`mbr_gid_to_uuid:
    0x7fffc09ae880 <+0>: jmpq   *0x8e3dd12(%rip)          ; (void *)0x00007fffc09f84b2: mbr_gid_to_uuid

libsystem_c.dylib`mbr_uid_to_uuid:
    0x7fffc09ae886 <+0>: jmpq   *0x8e3dd14(%rip)          ; (void *)0x00007fffc09e1bcd: mbr_uid_to_uuid

libsystem_c.dylib`mbr_uuid_to_id:
    0x7fffc09ae88c <+0>: jmpq   *0x8e3dd16(%rip)          ; (void *)0x00007fffc09f84dc: mbr_uuid_to_id
Target 0: (arangodbtests) stopped.
(lldb) 
Process 97510 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into
    frame #0: 0x00007fffc0a741e8 libsystem_malloc.dylib`malloc
libsystem_malloc.dylib`malloc:
->  0x7fffc0a741e8 <+0>: pushq  %rbp
    0x7fffc0a741e9 <+1>: movq   %rsp, %rbp
    0x7fffc0a741ec <+4>: pushq  %rbx
    0x7fffc0a741ed <+5>: pushq  %rax
Target 0: (arangodbtests) stopped.

from mimalloc.

ObiWahn avatar ObiWahn commented on July 19, 2024

Any idea why the allocations could be partially replaced?

After adding an extra override for strdup the test was successful. Do you think it is possible that there is some non overridden special allocation function that is used by clangs osx strdup implementation?

from mimalloc.

daanx avatar daanx commented on July 19, 2024

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 strdup calls an internal allocation routine... not sure. Also, I read somewhere that one cannot interpose functions in system libraries? So perhaps more is needed. For now, I will concentrate on making at least the basic scenarios work and protect against recursion in the thread local storage allocation.

from mimalloc.

daanx avatar daanx commented on July 19, 2024

I think the latest dev branch should now work with MI_INTERPOSE=ON on static-overload test. The dynamic one is still being worked on.

from mimalloc.

ObiWahn avatar ObiWahn commented on July 19, 2024

Thank You! Unfortunately we have still problems.

cupertino:arangodb-build jenkins$ cmake -DCMAKE_BUILD_TYPE=Debug -DMI_CHECK_FULL=ON -DMI_INTERPOSE=ON ../arangodb on our mimalloc branch

[100%] Built target arangodbtests
cupertino:arangodb-build jenkins$ MIMALLOC_VERBOSE=1 lldb -- ./bin/arangodbtests --gtest_filter=SimpleHttpClientCommunicatorTest.requests_are_properly_aborted
(lldb) target create "./bin/arangodbtests"
Current executable set to './bin/arangodbtests' (x86_64).
(lldb) settings set -- target.run-args  "--gtest_filter=SimpleHttpClientCommunicatorTest.requests_are_properly_aborted"
(lldb) r
Process 31879 launched: './bin/arangodbtests' (x86_64)
mimalloc: option 'secure': 0
mimalloc: option 'pool_commit': 0
mimalloc: assertion failed: at "/Users/jenkins/arangodb/3rdParty/mimalloc/src/page.c":101, _mi_page_is_valid
  assertion: "segment->thread_id == page->heap->thread_id"
Process 31879 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fffc0a21d42 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
->  0x7fffc0a21d42 <+10>: jae    0x7fffc0a21d4c            ; <+20>
    0x7fffc0a21d44 <+12>: movq   %rax, %rdi
    0x7fffc0a21d47 <+15>: jmp    0x7fffc0a1acaf            ; cerror_nocancel
    0x7fffc0a21d4c <+20>: retq
Target 0: (arangodbtests) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fffc0a21d42 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fffc0b0f457 libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x00007fffc0987420 libsystem_c.dylib`abort + 129
    frame #3: 0x000000010563927f arangodbtests`_mi_assert_fail(assertion="segment->thread_id == page->heap->thread_id", fname="/Users/jenkins/arangodb/3rdParty/mimalloc/src/page.c", line=101, func="_mi_page_is_valid") at options.c:136                                                                                                                                                  
    frame #4: 0x0000000105631126 arangodbtests`_mi_page_is_valid(page=0x0000000111000060) at page.c:101
    frame #5: 0x0000000105633710 arangodbtests`mi_page_fresh_alloc(heap=0x00000001095f2058, pq=0x00000001095f2560, block_size=96) at page.c:219
    frame #6: 0x0000000105634872 arangodbtests`mi_page_fresh(heap=0x00000001095f2058, pq=0x00000001095f2560) at page.c:238
    frame #7: 0x00000001056345f3 arangodbtests`mi_page_queue_find_free_ex(heap=0x00000001095f2058, pq=0x00000001095f2560) at page.c:606
    frame #8: 0x000000010563327d arangodbtests`mi_find_free_page(heap=0x00000001095f2058, size=96) at page.c:634
    frame #9: 0x0000000105632e9f arangodbtests`_mi_malloc_generic(heap=0x00000001095f2058, size=96) at page.c:701
    frame #10: 0x00000001056351dd arangodbtests`_mi_page_malloc(heap=0x00000001095f2058, page=0x000000010783a238, size=96) at alloc.c:27
    frame #11: 0x00000001056353e4 arangodbtests`mi_heap_malloc_small(heap=0x00000001095f2058, size=96) at alloc.c:49
    frame #12: 0x00000001056355f0 arangodbtests`mi_heap_malloc(heap=0x00000001095f2058, size=96) at alloc.c:69
    frame #13: 0x000000010563496d arangodbtests`mi_malloc(size=96) at alloc.c:84
    frame #14: 0x0000000105634cc5 arangodbtests`_Znwm(n=96) at alloc-override.c:97
    frame #15: 0x000000010003edb5 arangodbtests`std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::allocate(unsigned long) [inlined] std::__1::__allocate(__size=96) at new:226                                         
    frame #16: 0x000000010003edac arangodbtests`std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::allocate(unsigned long) [inlined] std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::_
_1::allocator<char> > >::allocate(this=0x0000000109639358, __n=4, (null)=0x0000000000000000) at memory:1771
    frame #17: 0x000000010003ece6 arangodbtests`std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::allocate(unsigned long) [inlined] std::__1::allocator_traits<std::__1::allocator<std::__1::basic_string<char, std::__1
::char_traits<char>, std::__1::allocator<char> > > >::allocate(__a=0x0000000109639358, __n=4) at memory:1526
    frame #18: 0x000000010003ecca arangodbtests`std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::allocate(this=0x0000000109639348 size=1, __n=4) at vector:925                                                        
    frame #19: 0x00000001000ae889 arangodbtests`::__cxx_global_var_init.7() [inlined] std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::vector(this=0x0000000109639348 size=1, __il=([0] = "/Target/ToDo/", [1] = "/Targ
et/Pending/", [2] = "/Target/Finished/", [3] = "/Target/Failed/")) at vector:1278
    frame #20: 0x00000001000ae79d arangodbtests`::__cxx_global_var_init.7() [inlined] std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::vector(this=0x0000000109639348 size=1, __il=([0] = "/Target/ToDo/", [1] = "/Targ
et/Pending/", [2] = "/Target/Finished/", [3] = "/Target/Failed/")) at vector:1272
    frame #21: 0x00000001000ae773 arangodbtests`::__cxx_global_var_init.7() at Job.h:43
    frame #22: 0x00000001000afa7c arangodbtests`_GLOBAL__sub_I_ActiveFailoverTest.cpp at ActiveFailoverTest.cpp:0
    frame #23: 0x000000010f892a1b dyld`ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 385
    frame #24: 0x000000010f892c1e dyld`ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 40
    frame #25: 0x000000010f88e4aa dyld`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 338                                                                                                                                                                           
    frame #26: 0x000000010f88d524 dyld`ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 138                                                                                                                                                                                            
    frame #27: 0x000000010f88d5b9 dyld`ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 75
    frame #28: 0x000000010f87f47a dyld`dyld::initializeMainExecutable() + 195
    frame #29: 0x000000010f8838c6 dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 3966
    frame #30: 0x000000010f87e249 dyld`dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) + 470
    frame #31: 0x000000010f87e036 dyld`_dyld_start + 54
(lldb) f 4
frame #4: 0x0000000105631126 arangodbtests`_mi_page_is_valid(page=0x0000000111000060) at page.c:101
   98     mi_assert_internal(page->cookie != 0);
   99     if (page->heap!=NULL) {
   100      mi_segment_t* segment = _mi_page_segment(page);
-> 101      mi_assert_internal(segment->thread_id == page->heap->thread_id);
   102      mi_page_queue_t* pq = mi_page_queue_of(page);
   103      mi_assert_internal(mi_page_queue_contains(pq, page));
   104      mi_assert_internal(pq->block_size==page->block_size || page->block_size > MI_LARGE_SIZE_MAX || page->flags.in_full);
(lldb) p segment->thread_id
(uintptr_t) $0 = 140736574047168
(lldb) p page->heap->thread_id
(uintptr_t) $1 = 0

from mimalloc.

daanx avatar daanx commented on July 19, 2024

Good to hear there is progress -- just to confirm , the static-override test passes now right?
Also, the new error is "better" as it is an assertion failure in mimalloc (so happy we have thorough invariant checking!), and it seems to have started the actual program instead of having trouble during the dyld loading.

Actually, this could be related to another issue in the dev branch -- can you check you have the latest dev commits (in particular 1587058) ? Also, cmake the debug version with -DMI_CHECK_FULL=ON to ensure all invariants are checked continuously.

Apologies for your trouble, but your feedback is very helpful to get automatic overriding to work well on macOS.

from mimalloc.

ObiWahn avatar ObiWahn commented on July 19, 2024

Sources upgraded maybe 3 hours ago from mimalloc/master

cupertino:bin jenkins$ MIMALLOC_VERBOSE=1 lldb -- ./static-override
(lldb) target create "./static-override"                                                 
Current executable set to './static-override' (x86_64).
(lldb) r
Process 34562 launched: './static-override' (x86_64)
mimalloc: process init: 0x7fffc980c3c0                                                   
mimalloc: debug level : 3
mimalloc: option 'secure': 0
mimalloc: option 'pool_commit': 0
mimalloc: option 'show_errors': 3
mimalloc: error: trying to mi_free a pointer that does not point to a valid heap space: 0x100100100                                                                                 
mimalloc: assertion failed: at "/Users/jenkins/arangodb/3rdParty/mimalloc/src/options.c":121, _mi_error_message                                                                     
  assertion: "false"
Process 34562 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fffc0a21d42 libsystem_kernel.dylib`__pthread_kill + 10              
libsystem_kernel.dylib`__pthread_kill:
->  0x7fffc0a21d42 <+10>: jae    0x7fffc0a21d4c            ; <+20>                       
    0x7fffc0a21d44 <+12>: movq   %rax, %rdi
    0x7fffc0a21d47 <+15>: jmp    0x7fffc0a1acaf            ; cerror_nocancel
    0x7fffc0a21d4c <+20>: retq
Target 0: (static-override) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fffc0a21d42 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fffc0b0f457 libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x00007fffc0987420 libsystem_c.dylib`abort + 129
    frame #3: 0x000000010000f04f static-override`_mi_assert_fail(assertion="false", fname="/Users/jenkins/arangodb/3rdParty/mimalloc/src/options.c", line=121, func="_mi_error_message") at options.c:136
    frame #4: 0x000000010000fad4 static-override`_mi_error_message(fmt="trying to mi_free a pointer that does not point to a valid heap space: %p\n") at options.c:121              
    frame #5: 0x000000010000a973 static-override`mi_free(p=0x0000000100100100) at alloc.c:212                                                                                       
    frame #6: 0x000000010000a8b5 static-override`free(p=0x0000000100100100) at alloc-override.c:64                                                                                  
    frame #7: 0x00000001000016c5 static-override`main at main-override.c:21
    frame #8: 0x00007fffc08f3235 libdyld.dylib`start + 1
(lldb)                                                                           
211    if (mi_unlikely(_mi_ptr_cookie(segment) != segment->cookie)) {
-> 212      _mi_error_message("trying to mi_free a pointer that does not point to a valid heap space: %p\n", p);
   213      return;

Thank you for your time!

from mimalloc.

ObiWahn avatar ObiWahn commented on July 19, 2024

I there anything I can do? Should I try a newer version?

from mimalloc.

ObiWahn avatar ObiWahn commented on July 19, 2024

No problem it was the same for me, I actually forgot to check the thread for some days ;)

from mimalloc.

michaeleisel avatar michaeleisel commented on July 19, 2024

Why not replace the default zone, rather using interposing, like jemalloc does: https://github.com/jemalloc/jemalloc/blob/dev/src/zone.c

from mimalloc.

michaeleisel avatar michaeleisel commented on July 19, 2024

Oops, I see that there is indeed a zone-based way of injecting mimalloc

from mimalloc.

michaeleisel avatar michaeleisel commented on July 19, 2024

@daanx just curious to see what the status of this is. I'm having similar issues myself

from mimalloc.

daanx avatar daanx commented on July 19, 2024

Finally I think the current version of mimalloc v1.6.1 is working on macOSX.
Thank you @erikolofsson for your insights! (I did take a slightly different approach though)
I did a bit of testing with dynamic and static linking and it worked for those cases. I did a bit of light benchmarking and mimalloc seems quite a bit faster than the default allocator:

              mimalloc           default        speedup
cfrac          6.124s              13.171s       2.15x
mstressN       2.090s               5.960s       2.85x
larsonN       14.588s              63.369s       4.34x
rptestN       292742ops/s          245539ops/s   1.19x

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.

from mimalloc.

michaeleisel avatar michaeleisel commented on July 19, 2024

It's crashing for me when using XcodeProj

from mimalloc.

michaeleisel avatar michaeleisel commented on July 19, 2024

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

from mimalloc.

michaeleisel avatar michaeleisel commented on July 19, 2024

Ah, explained much more thoroughly by Eric above 😛

from mimalloc.

daanx avatar daanx commented on July 19, 2024

@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 free is checking for ownership on macOS (using cfree) but the zone_free calls just mi_free.
Can you try to change that into a call to mi_cfree to see if that works for XCodeProj?

from mimalloc.

Harold2017 avatar Harold2017 commented on July 19, 2024

my code works well with tcmalloc/jemalloc/tbbmalloc but failed with mimalloc

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 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free")

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"
}

from mimalloc.

anthonyalayo avatar anthonyalayo commented on July 19, 2024

I am also getting the following errors. Is it safe to say that the static object implementation doesn't work for OSX @daanx ?

appTest(3748,0x1ef6e8100) malloc: *** error for object 0x20000020080: pointer being freed was not allocated
appTest(3748,0x1ef6e8100) malloc: *** set a breakpoint in malloc_error_break to debug
[1]    3748 abort      ./build/bin/appTest

from mimalloc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.