windowjs / windowjs

Window.js is an open-source Javascript runtime for desktop graphics programming.

Home Page:https://windowjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix crash at shutdown on Windows debug builds with MSVC

joaodasilva opened this issue · comments

The program in attachment crashes after 10 to 100 runs on debug builds with MSVC on Windows.

This seems to come from a destructor running at shutdown, possibly reaching for memory from an object that has already been destroyed. The issue only reproes on early exits via std::exit, which is often used in child processes (and in tests).

Window.js doesn't have any destructors at shutdown, and this is likely coming from one of the libraries used. It's quite tricky to pin this down.

The temporary fix at in commit f56ae2f uses std::quick_exit instead, to bypass the atexit callbacks. This isn't great; this bug is to change that back to std::exit and fix the shutdown issue.

https://gist.github.com/joaodasilva/f5fe471c7b27a2606689c6aeeb7398ed

This still reproes with debug MSVC builds and using std::exit.

The child exits with status 3221225477, which is STATUS_ACCESS_VIOLATION and suggests reading invalid memory at shutdown.