Repository navigation
fix(libc): run guest finalizers before driver shutdown - #5978
adriadam10 merged 3 commits into
Conversation
|
Windows validation of #5843 + this PR, from the #5931 report: Setup: Windows 11 Pro (26200), Core i5-13400 (passes the CPU guard), WinLibs GCC 15.2.0 r7, Release, Conflicts when this PR goes on top of #5843:
Results:
Linux not run. AI-assisted. |
c6b42bf to
f619f96
Compare
|
Rebased onto current |
|
Hosted checks have now finished: Ubuntu, Windows and macOS relinker jobs all pass; register-context and write-watch jobs pass as well. Linux and Windows full-build jobs were skipped by path filters. The five local exit CTests still stop at this host’s CPU-feature guard before their test bodies, so I am not claiming a local runtime pass. The Windows title results earlier in this thread remain @ahmad3a4’s separate validation of the prior stacked head. |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
The CTest half, on a host with AVX2 (Ubuntu 24.04, i7-13700K, GCC 13.3, Release),
With Syobon Action (PPSA47402), closing the window 20 s in exits 0 with #5843 alone and with both PRs; AI-assisted: yes |
|
I prepared a small supplemental regression for the nested-exit coverage request. It extends Windows 11 Pro build 26300, i7-14700K, WinLibs GCC 15.2.0 r7, Release:
The runtime build used main The production changes remain the work of the existing PR authors. The supplemental test patch below addresses the remaining coverage request. Supplemental test patchdiff --git a/core/libs/tests/GuestSystemExit.cpp b/core/libs/tests/GuestSystemExit.cpp
index bcfe623a5..35c1882d9 100644
--- a/core/libs/tests/GuestSystemExit.cpp
+++ b/core/libs/tests/GuestSystemExit.cpp
@@ -90,7 +90,10 @@ void AppendMarker(const std::string& line) {
}
void MainShutdown() { AppendMarker("shutdown"); }
void SecondaryShutdown() { AppendMarker("secondary shutdown"); }
-void APS5_VABI RemainingHandler(void*) { AppendMarker("remaining handler"); }
+void APS5_VABI RemainingHandler(void*) {
+ if (LibcShutdownToken_nid_postfix().stop_requested()) std::_Exit(8);
+ AppendMarker("remaining handler");
+}
void APS5_VABI ExitingHandler(void*) { exit_nid_postfix(7); }
void GuestExitShutdown() { AppendMarker("shutdown"); }
void APS5_VABI CheckShutdownStillRunning(void*) {
@@ -135,7 +138,7 @@ int DriveNestedExit() {
std::error_code ignored;
std::filesystem::remove(marker, ignored);
Require(code == 7);
- Require(text == "remaining handler\n");
+ Require(text == "remaining handler\nshutdown\n");
std::puts("Guest nested exit completed");
return 0;
}
@@ -209,6 +212,7 @@ int main(int argc, char** argv) {
return DriveNestedExit();
}
if (argc > firstArgument && std::strcmp(argv[firstArgument], "--nested-exit") == 0) {
+ LibcRegisterShutdown_nid_postfix(GuestExitShutdown);
Require(__cxa_atexit_nid_postfix(RemainingHandler, nullptr, nullptr) == 0);
Require(__cxa_atexit_nid_postfix(ExitingHandler, nullptr, nullptr) == 0);
exit_nid_postfix(0); |
f619f96 to
8412834
Compare
|
The latest Windows relinker job built successfully and passed 176/177 CTest cases. Its only failure is |
|
Update: the Windows full-build job on current |
|
Follow-up: PR #6583 now passes the |
|
The current Windows relinker check has the same |
|
The current Windows relinker failure is in the shared |
|
Update: the current head of #6583 ( |
|
The only failing check in this run is |
|
I rechecked the current Windows relinker failure: it is the same |
8412834 to
22f1c99
Compare
|
I rebased the two existing commits onto current |
…h modes Co-Authored-By: Claude <noreply@anthropic.com>
|
Rebased onto current Checked on the rebased head: build and scoped ctest green for all exit tests ( |
22f1c99 to
160ba25
Compare
|
Thanks for the rebase and for adding the |
…tarts the exit Since boykopovar#5978, StartExit only parks the other guest threads and exit runs LibcRunShutdown itself, so LoadExec's three exits (the converted executable on Windows and Linux, and the host executable) now call LibcStartExit and then LibcRunShutdown, as exit does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
For an explicit guest
exit()or return from main, run the guest's C++ finalizers before the AGC/VideoOut shutdown callbacks. This keeps those drivers available to finalizers that use them. The shutdown callbacks still run once, after the finalizers, including when a finalizer calls nestedexit().This is the explicit guest-exit path from #5931. Host window-close requests continue through #5843's no-handler path. Depends on #5843 (which depends on #5236).
Tested
main8cd937e29;git diff --checkand the template-aware conventions check pass.tests/guest_system_exit_testssuccessfully (712 build steps, includinglibc.prx,libSceSystemService.prx, and the test executable).guest_exit_finalizers_before_shutdown,guest_system_exit,guest_return_from_main,guest_system_relaunch, andguest_nested_exit. All five processes aborted before test logic at the emulator host-CPU guard: this Xeon E5-1620 v2 lacks LZCNT, BMI1/2, MOVBE, AVX2, and FMA. No CTest case is reported as passing on this host.Process.cppprobe passed on the pre-rebase head; it has not been rerun on this rebased head. No Windows or title runtime was tested.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository