microsoft / microsoft/mimalloc

Crash in `mi_process_done` on M1 (when exiting)

Open
#491 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

When using mimalloc as a static library in a standalone process, `mi_process_done` calls `mi_collect`:

https://github.com/microsoft/mimalloc/blob/0560fc27c08d28d523b7f741a42deb26cd01c0c6/src/init.c#L536-L544

This causes a crash sometimes:

![image](https://user-images.githubusercontent.com/709451/144234058-4c437153-81f1-487b-8eda-63b4a364cf9e.png)

I suspect the cause might be related to resizing buffers originally created in a different thread, sometime earlier in the application's lifecycle? I've noticed occasional crashes in mimalloc when reallocating arrays.

In this application's case, we don't actually need to call `mi_collect(true)` since the program is an executable and it statically links mimalloc?

Incase it helps, here are stats from activity monitor. I believe the 390 GB of virtual memory is mostly due to JavaScriptCore's [Gigacage](https://phakeobj.netlify.app/posts/gigacage/)


Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/init.c at the mi_process_done and mi_collect calls linked in the issue, then investigate the reported standalone statically linked M1 exit path and the occasional reallocating-array crashes. Done means the reported crash is explained and no longer occurs in that scenario; the issue does not name a test to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.