Skip to content

TEST: Verify clean process exit after HTTP server lifecycle#1464

Closed
EricGT wants to merge 1 commit intoSWI-Prolog:masterfrom
EricGT:test-thread-exit-http
Closed

TEST: Verify clean process exit after HTTP server lifecycle#1464
EricGT wants to merge 1 commit intoSWI-Prolog:masterfrom
EricGT:test-thread-exit-http

Conversation

@EricGT
Copy link
Contributor

@EricGT EricGT commented Feb 14, 2026

Uses HTTP server start/stop pattern to reliably reproduce threading cleanup issues. Details in commit message.

Test that a process using HTTP server lifecycle (start/stop) exits
cleanly without crashing. On Windows with PThreads4W, the library's
DllMain(DLL_PROCESS_DETACH) runs after PL_cleanup() has freed thread
data. Without explicit cleanup via pthread_win32_process_detach_np(),
this causes ACCESS_VIOLATION in Debug builds where the CRT fills
freed heap with 0xDD.

The test spawns a subprocess that starts and stops an HTTP server,
then halts. The HTTP server creates worker threads and allocates
enough memory that PL_cleanup() triggers the crash in Debug builds.
The parent verifies the exit code is 0 (not a crash).

@see pthread_win32_process_detach_np() in src/pl-init.c
@JanWielemaker
Copy link
Member

Integrated into #1463

@EricGT EricGT deleted the test-thread-exit-http branch February 14, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants