Use std::quick_exit when exiting

Open
#1,396 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

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.

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.

Dominant language
C++
Stars
330
Forks
237
Avg merge
1d 3h
Merged PRs (30d)
20

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HaxeFoundation/hxcpp

All issues in HaxeFoundation/hxcpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.