microsoft / microsoft/mimalloc
Avoiding mi_cfree on mac interpose mode
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 13.4k
- Fork
- 1.2k
- Merge medio
- 4g 45m
- PR unite (30g)
- 13
Descrizione
I think you might just need to interpose malloc_default_zone too. This is what asan ends up doing, among other things (I suspect the other things it interposes are related to asan's functionality): https://github.com/llvm/llvm-project/blob/350fafabe9d3bda75e80bf077303eb5a09130b53/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc#L85
You also can try __attribute__((constructor(0))) to try to get loaded earlier than with normal __attribute__((constructor)). Not sure if that matters for shared libs, probably not, but it can help for static linking.
This is a somewhat messy commit (includes unrelated whitespace changes, XXX comments, and doesn't reuse the existing interpose stuff) that does these and seems to work for me. https://github.com/thomcc/mimalloc/commit/52b5237028a27644ffc4e8a671d7b884a2fa7379
Unfortunately, IDK how to trigger the bad behavior that lead to you using mi_cfree in the first place, so IDK if it fixes it. That said, if you want I can PR it.
Still it's a bummer that doing this in a statically linked build isn't viable how it is on other unixes...
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia leggendo compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc in corrispondenza del codice di interposizione malloc_default_zone collegato, quindi confronta il commit mimalloc proposto 52b5237028a27644ffc4e8a671d7b884a2fa7379. Determina se le modifiche all’interposizione e al costruttore impediscono il comportamento mi_cfree segnalato, tenendo presente che l’issue non fornisce un modo per riprodurlo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, macos
- Ambito
- operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100