Files
reims-vgpu/docs
Anees Iqbal 64fa79edf5 🐛 Never destroy the bundle's statics as its process exits
A static or global object with a destructor is destroyed as the process exits,
while the app's other threads may still run the bundle's code: a command
buffer's completion, a decode, a log line. A thread that then took one of the
bundle's static locks would end the process with "mutex lock failed: Invalid
argument" as the app quit, so a guest app could abort at quit, with a crash
report. No run has shown it. A review after the shell_tests race found 42 such
objects in guest/bundle/src: locks, a condition variable, sets, strings, class
tables, a shared pointer, and the video driver's session and driver lists. None
has a destructor whose work the exit needs (a flush, a file's close).

Each is now never destroyed (static T &x = *new T(), as RgfxLibraryStream's
lock already was). A guest sees nothing new while it runs; at its exit the
bundle frees none of them, and a thread still in the bundle finds them whole.
tests/bundle_exit_check.sh, first in the bundle's make test, fails where the
bundle imports ___cxa_atexit, which the compiler calls to register a destructor
at exit, and names the objects that do: on the tree before this commit it fails
for x86_64 and arm64, naming 30 objects. The bundle is the guest's only
user-space code; the kexts do not exit. Both guest kext sets are rebuilt
(RgfxGate carries the bundle), and docs/lessons.md has the trap.
2026-12-03 04:15:27 -08:00
..