Access violation at exit on Windows when a collection has just run
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 18/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp
- Lĩnh vực
- operating-systems
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C++
- Star
- 330
- Fork
- 237
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 20
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của HaxeFoundation/hxcpp
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
HaxeFoundation/hxcpp#1217 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug regression
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 40/100
HaxeFoundation/hxcpp#1464 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Abstract function robustnessĐang mởbug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 18/100
HaxeFoundation/hxcpp#1454 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
HaxeFoundation/hxcpp#1452 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Review TLS fixĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
HaxeFoundation/hxcpp#1446 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của HaxeFoundation/hxcpp
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
Solution YAML loader rejects comments and blank lines before nested settingsCó thể đã có người làm @labishbardiya đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
RunanywhereAI/runanywhere-sdks#1345 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
CachyOS/packageinstaller#156 ·
Maintainer thường phản hồi trong vòng 2 ngày