HaxeFoundation / HaxeFoundation/hxcpp

Use std::quick_exit when exiting

Open
#1,396 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
330
Forks
227
Avg merge
2d 16h
Merged PRs (30d)
18

Description

I can't remember the exact details at this point, but during hxcoro development we ran into a problem on cpp when integrating libuv. Roughly, after the program had successfully ran the runtime starts to tear down thread local stuff by running destructors and some gcc specific "on exit" callbacks in libuv. This caused a race with the hxcpp GC being unloaded causing a segfault on program exit.

I think we should start using `std::quick_exit`, both when the user calls `Sys.exit` and when the program completes gracefully. This will prevent the destructors of any thread local stuff being called, which is fine as we're about to exit anyway. If there is something we want to run we can use `std::at_quick_exit`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the hxcpp runtime entry points for Sys.exit and graceful program completion, then review how they currently tear down threads, the GC, and libuv. Confirm how std::quick_exit and std::at_quick_exit should affect both exit paths, and verify that programs no longer race during shutdown without breaking graceful completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.