mimalloc: Segmantation fault for very big data on 32-bit linux build

I have segmentation error only for Release build, when I tired to work with very big data (about 1GB arrays) on 32 bit linux os (mimalloc 1.6.1). I build app with additional debug info, and there is next core dump:

received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xe358bb40 (LWP 16919)] mi_segment_init (segment=0x94400000, segment@entry=0x0, required=required@entry=0, page_kind=page_kind@entry=MI_PAGE_SMALL, page_shift=15, tld=0xd856b644, os_tld=0xd856b684) at /home/sies_unit/.conan/data/mimalloc/1.6.1/sies/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/segment.c:635 635 /home/sies_unit/.conan/data/mimalloc/1.6.1/sies/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/segment.c: Нет такого файла или каталога. (gdb) bt -full #0 mi_segment_init (segment=0x94400000, segment@entry=0x0, required=required@entry=0, page_kind=page_kind@entry=MI_PAGE_SMALL, page_shift=15, tld=0xd856b644, os_tld=0xd856b684) at /home/my_app/.conan/data/mimalloc/1.6.1/project/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/segment.c:635 memid = 1088 mem_large = false capacity = 64 info_size = 4096 pre_size = 8192 segment_size = <optimized out> eager_delayed = <optimized out> eager = <optimized out> commit = true pages_still_good = false is_zero = true #1 0xf7fb10b2 in mi_segment_alloc (os_tld=0xd856b684, tld=0xd856b644, page_shift=15, page_kind=MI_PAGE_SMALL, required=0) at /home/my_app/.conan/data/mimalloc/1.6.1/project/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/segment.c:682 No locals. #2 mi_segment_reclaim_or_alloc (heap=0xd856b000, block_size=8192, page_kind=MI_PAGE_SMALL, page_shift=15, tld=<optimized out>, os_tld=0xd856b684) at /home/my_app/.conan/data/mimalloc/1.6.1/project/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/segment.c:1201 segment = 0x0 reclaimed = false page_shift = 15 heap = 0xd856b000 os_tld = 0xd856b684 tld = 0xd856b644 page_kind = MI_PAGE_SMALL block_size = 8192 segment = 0x0 reclaimed = <optimized out> #3 0xf7fb12ff in mi_segment_page_alloc (heap=heap@entry=0xd856b000, block_size=block_size@entry=8192, kind=kind@entry=MI_PAGE_SMALL, page_shift=15, tld=0xd856b644, os_tld=0xd856b684) at /home/my_app/.conan/data/mimalloc/1.6.1/project/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/segment.c:1234 segment = <optimized out> free_queue = <optimized out> page = <optimized out> #4 0xf7fb1745 in mi_segment_small_page_alloc (os_tld=0xd856b684, tld=0xd856b644, block_size=8192, heap=0xd856b000) at /home/my_app/.conan/data/mimalloc/1.6.1/project/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/segment.c:1251 No locals. #5 _mi_segment_page_alloc (heap=0xd856b000, block_size=8192, tld=0xd856b644, os_tld=0xd856b684) at /home/my_app/.conan/data/mimalloc/1.6.1/project/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/segment.c:1321 page = <optimized out> #6 0xf7fb1c1b in mi_page_fresh_alloc (heap=heap@entry=0xd856b000, pq=pq@entry=0xd856b3e8, block_size=8192) at /home/my_app/.conan/data/mimalloc/1.6.1/project/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/page.c:247 page = <optimized out> #7 0xf7fb31ca in mi_page_fresh (pq=0xd856b3e8, heap=0xd856b000) at /home/my_app/.conan/data/mimalloc/1.6.1/project/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/page.c:264 page = <optimized out> page = <optimized out> #8 mi_page_queue_find_free_ex (heap=0xd856b000, pq=0xd856b3e8, first_try=<optimized out>) at /home/my_app/.conan/data/mimalloc/1.6.1/project/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/page.c:679 count = <optimized out> page = 0x0 #9 0xf7fb33c2 in mi_find_free_page (size=8192, heap=0xd856b000) at /home/my_app/.conan/data/mimalloc/1.6.1/project/testing/build/a98ffa6b232ae76f738ec2524a9fc9ba058249ac/source_subfolder/src/page.c:713 pq = 0xd856b3e8 page = 0x9f400c0c pq = <optimized out>

As you can see, the problem, that allocated segment pointer referenced to corrupted data. In Debug build there is no problem, therefore, I think, that problem in padding of allocated memory.

I tried to locolize problem, but still cann’t to do it. From other side, I cann’t share my production code.

I will continue try to catch this problem by unit test, but hope, this information will provide any ideas about this segmentation.

Thank you for attention!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 34

Commits related to this issue

Most upvoted comments

@daanx thank you, I will try to check in nearest days!

Ah I see. Thanks for the clarification. I will try to reproduce and test more somewhere this week as I think it does point to an error in mimalloc itself (that normally does not show up but is triggered by the memory cleanup addition)

@daanx I tired to replace condition - https://github.com/microsoft/mimalloc/pull/225/commits/c1f07a74a1889e76ed7b9adfd71b5a600e1c0c16 and set reset_decommit to zero - https://github.com/microsoft/mimalloc/pull/225/commits/64e722f7546692488d2cff306003551f96b78942

The result in my production code is the same - segmentation fault at 0x944000000 segment address. But, replace condition improved pipeline in my fork with zerofictaion memory - https://github.com/microsoft/mimalloc/pull/225/checks, now only windows debug build is failed.