Access violation at exit on Windows when a collection has just run
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 18/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- operating-systems
Direzione di ricerca
The fault is in src/hx/gc/Immix.cpp: start at finishThreadJob and sThreadPoolLock, then follow how tpjAsyncZero jobs run on GlobalAllocator::SThreadLoop and when the static HxMutex is destroyed at exit. The issue has no standalone reproduction, so first confirm the ordering problem on Windows. Done means a collection followed by Sys.exit no longer faults, and the collector threads are stopped or joined before the lock is torn down.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version: hxcpp 4.3.2, Haxe 4.3.6, MSVC, x64 (GitHub's windows-latest runner).
What happens: a program that calls Sys.exit, or returns from main, shortly after a collection can end with an access violation instead of its exit code. It is intermittent: it depends on whether the collector's threads are still zeroing memory when the C runtime runs static destructors.
Where: with every thread's stack printed at the fault (cdb):
- The main thread is in the C runtime's
common_exit, past the static destructors, called fromSys.exit. - The faulting thread is a collector thread:
GlobalAllocator::SThreadLoop->ThreadLoop->finishThreadJob->TAutoLock<HxMutex>->RtlEnterCriticalSection->RtlpWaitOnCriticalSection.
Why, from src/hx/gc/Immix.cpp: a collection ends by starting a job (tpjAsyncZero or tpjAsyncZeroJit) that zeroes reclaimed memory on the collector's threads, and does not wait for it. Each thread calls finishThreadJob when it is done, which locks sThreadPoolLock, a static HxMutex. On Windows ~HxMutex is DeleteCriticalSection, which exit runs while those threads are still going, so a thread that finishes afterwards enters a critical section that has been deleted.
To reproduce: it was met in a test program that allocates heavily, forces a collection (cpp.vm.Gc.run(true)), prints a line and exits at once; the same program that did more work after its collection did not fault. It has not been reduced to a standalone program.
Possible fixes: wait for, or stop, the thread jobs before the lock is destroyed; or do not destroy sThreadPoolLock at exit.
Way round in the meantime: flush standard output and call _Exit, so that no static destructor runs.
- Lingua principale
- C++
- Stelle
- 330
- Fork
- 237
- Merge medio
- 1g 3h
- PR unite (30g)
- 20
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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.
Altre issue di HaxeFoundation/hxcpp
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
HaxeFoundation/hxcpp#1217 ·
I maintainer di solito rispondono entro 1 giorno
-
bug regression
Difficoltà 3/5 1-2 giorni Idoneità per principianti 40/100
HaxeFoundation/hxcpp#1464 ·
I maintainer di solito rispondono entro 1 giorno
-
Abstract function robustnessApertabug
Difficoltà 4/5 1-2 giorni Idoneità per principianti 18/100
HaxeFoundation/hxcpp#1454 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
HaxeFoundation/hxcpp#1452 ·
I maintainer di solito rispondono entro 1 giorno
-
Review TLS fixAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
HaxeFoundation/hxcpp#1446 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di HaxeFoundation/hxcpp
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
-
Solution YAML loader rejects comments and blank lines before nested settingsForse già presa @labishbardiya l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
RunanywhereAI/runanywhere-sdks#1345 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
CachyOS/packageinstaller#156 ·
I maintainer di solito rispondono entro 2 giorni