microsoft / microsoft/mimalloc
Incorrect assertion during memory release in thread (memory allocated in main thread)
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 13.4k
- Forks
- 1.2k
- Avg merge
- 4d 45m
- Merged PRs (30d)
- 13
Description
Hello,
Here is my main.cpp:
#include <thread>
using namespace std;
int main()
{
char* a = new char[1ull << 25];
thread th([&] {
delete [] a;
});
th.join();
}
compilation: g++ main.cpp -I mimalloc mimalloc/libmimalloc-debug.a -pthread -o main
run:
./main
mimalloc: assertion failed: at "mimalloc-2.0.0/src/init.c":268, _mi_heap_done
assertion: "heap->tld->segments.count == 0 || heap->thread_id != _mi_thread_id()"
Aborted (core dumped)
It does not occur in 1.7.0 or in release.
When the alloc size is 1<<22 I get:
mimalloc: warning: mi_usable_size: pointer might not point to a valid heap region: 0x7f4ed4810000
(this may still be a valid very large allocation (over 64MiB))
mimalloc: warning: (yes, the previous pointer 0x7f4ed4810000 was valid after all)
mimalloc: warning: mi_usable_size: pointer might not point to a valid heap region: 0x7f4ed4810000
(this may still be a valid very large allocation (over 64MiB))
mimalloc: warning: (yes, the previous pointer 0x7f4ed4810000 was valid after all)
mimalloc: warning: mi_free: pointer might not point to a valid heap region: 0x7f4ed4810000
(this may still be a valid very large allocation (over 64MiB))
mimalloc: warning: (yes, the previous pointer 0x7f4ed4810000 was valid after all)
mimalloc: warning: mi_usable_size: pointer might not point to a valid heap region: 0x7f4ed4810000
(this may still be a valid very large allocation (over 64MiB))
mimalloc: warning: (yes, the previous pointer 0x7f4ed4810000 was valid after all)
mimalloc: assertion failed: at "/mnt/d/nauka/DEVELOPMENT/3rd-compress/2021-02-16/ONT-compress-dev/3rd-compress/mimalloc-2.0.0/src/init.c":268, _mi_heap_done
assertion: "heap->tld->segments.count == 0 || heap->thread_id != _mi_thread_id()"
Aborted (core dumped)
For 1 << 21 everything seems to be fine.
Any ideas? Thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the provided main.cpp and the stated g++ command, then inspect src/init.c around line 268 and the _mi_heap_done assertion. Compare behavior with mimalloc 1.7.0 and the release build, including the 1<<21, 1<<22, and 1<<25 allocation sizes. Done means the threaded deallocation no longer triggers the assertion or warnings, with the relevant behavior covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- operating-systems, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100