Skip to content

Stop the Windows timer thread cooperatively - #838

Open
kevinushey wants to merge 2 commits into
r-lib:mainfrom
kevinushey:bugfix/windows-timer-cleanup
Open

kevinushey wants to merge 2 commits into
r-lib:mainfrom
kevinushey:bugfix/windows-timer-cleanup

Conversation

@kevinushey

Copy link
Copy Markdown
Contributor

Loading cli starts a timer thread that Windows cleanup currently cancels asynchronously, without waiting for it to terminate. Signal a stop event and join the worker instead, so it returns normally before its resources are released or its DLL is unloaded. Signaling the event wakes the worker immediately, even with a long tick interval.

This removes the architecture-specific cancellation workaround and the unchecked getenv("PROCESSOR_ARCHITECTURE") argument to strcmp(). The Unix worker retains its existing behavior.

Add Windows subprocess tests for missing architecture variables, timer restart, disabling the thread, process exit, and repeated namespace/DLL unloading. Long timer intervals and bounded subprocess timeouts check that shutdown does not wait for the next tick.

Related to #375 (recent report) and #494. The reported Windows crash has not been reproduced locally, so this is a candidate remedy that still needs confirmation on the affected installation.

Validation:

  • Built and installed the package on macOS ARM64 with R 4.6.1.
  • Full test suite: 2,367 passing assertions, no failures or warnings, and six skips, with inherited NO_COLOR unset. Four skips are the new Windows tests; two require source references.
  • Compiled src/thread.c for Windows x64 with MinGW GCC 14.2, POSIX threads, and warnings treated as errors. This checks compilation against Windows APIs; it is not a complete Rtools build or a native Windows runtime test.
  • git diff --check passes.

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.

1 participant