Repository navigation
[Golden Wattle] drive ppm vulnerability display off the session repositories, not env vars - #17823
Merged
kevinushey merged 3 commits intoJun 2, 2026
Conversation
… vars
Vulnerability badges in the Packages pane are intentionally not opt-in: they
should appear whenever the session is using a Posit Package Manager repository
(a PPM URL in getOption("repos")), including open-source / desktop RStudio. This
was made an explicit decision in 88778df "always try to provide vuln info if
available", which removed an env-var gate that had been applied incidentally.
The async rewrite in #17808 reintroduced that gate, adding isPpmIntegrationEnabled()
early-returns to both refreshVulnerabilitiesAsync() (C++) and
getVulnerabilityRequestPlan() (R). isPpmIntegrationEnabled() requires the
Workbench-injected PWB_PPM_* env vars, so any session that points options(repos)
at PPM by hand (without Workbench PPM integration configured) stopped showing
vulnerability badges entirely.
Remove both gates so enablement is once again driven by repository detection,
keeping the env-var gate only for the Workbench-only metadata column. Add a
cheap PPM-URL pre-filter so installed.packages() is still skipped for non-PPM
sessions, and add comments recording the motivation.
- guard .rs.ppm.fromRepositoryUrl against non-string/NA repo entries so an
NA in getOption("repos") no longer aborts the now-unconditional vuln plan
- soften the integration-gate comment (the env-var gate also feeds
ppm_integration_enabled in client session info)
- add tests: mixed PPM/non-PPM repos, installed.packages() skip for non-PPM
sessions, NA repo tolerance, and direct fromRepositoryUrl coverage
gtritchie
requested changes
Jun 2, 2026
kevinushey
added a commit
that referenced
this pull request
Jun 18, 2026
On project switch/close, the desktop session quits via exitEarly() -> ::exit(), which runs static/global destructors. The server_rpc file-scope io_context worker thread was launched detached and never stopped, so ~io_context() could run on the main thread while the worker was still inside run() -- undefined behavior that hangs on Windows (IOCP). This began affecting ordinary desktop users once the PPM vulnerability fetch (#17808) started driving async work on that io_context for any session using a Posit Package Manager repository (#17823). Retain a joinable handle for the server_rpc worker and stop+join it from exitEarly(), via a new core::thread::joinOrAbandonThread() helper that bounds the wait (timed_join) and detaches on timeout, so the exit path can never trade the teardown hang for an indefinite join hang. The helper never throws (safe to call from a destructor) and requires callers to state whether the thread needs interrupting, since io_context workers are not interruption points and must be released via io_context::stop(). The monitor io_context worker had the same latent race (stopped but never joined); fix it the same way. Migrate the other duplicated join/log/detach shutdown tails (OfflineService, ClientEventService, file monitor, ConsoleInputService, HttpConnectionListener) onto the shared helper; this also fixes a latent std::terminate in ConsoleInputService's destructor, which left its thread joinable on a join timeout. Addresses #18018.
kevinushey
added a commit
that referenced
this pull request
Jun 18, 2026
…18021) * fix windows hang on project switch from unstopped io_context workers On project switch/close, the desktop session quits via exitEarly() -> ::exit(), which runs static/global destructors. The server_rpc file-scope io_context worker thread was launched detached and never stopped, so ~io_context() could run on the main thread while the worker was still inside run() -- undefined behavior that hangs on Windows (IOCP). This began affecting ordinary desktop users once the PPM vulnerability fetch (#17808) started driving async work on that io_context for any session using a Posit Package Manager repository (#17823). Retain a joinable handle for the server_rpc worker and stop+join it from exitEarly(), via a new core::thread::joinOrAbandonThread() helper that bounds the wait (timed_join) and detaches on timeout, so the exit path can never trade the teardown hang for an indefinite join hang. The helper never throws (safe to call from a destructor) and requires callers to state whether the thread needs interrupting, since io_context workers are not interruption points and must be released via io_context::stop(). The monitor io_context worker had the same latent race (stopped but never joined); fix it the same way. Migrate the other duplicated join/log/detach shutdown tails (OfflineService, ClientEventService, file monitor, ConsoleInputService, HttpConnectionListener) onto the shared helper; this also fixes a latent std::terminate in ConsoleInputService's destructor, which left its thread joinable on a join timeout. Addresses #18018. * detect ppm repository urls with a trailing slash .rs.ppm.fromRepositoryUrl matched with a fully-anchored regex ending in (?<snapshot>[^/]+)$, so a repo URL with a trailing slash (e.g. ".../cran/latest/") did not match and yielded an empty vulnerability request plan. RStudio's own CRAN-mirror UI normalizes repo URLs with a trailing slash, so users who configured a PPM repo that way silently got no vulnerability badges. Tolerate an optional trailing slash in the detection regex. Addresses #18018. * migrate server child-reaper join onto joinOrAbandonThread ServerMain's shutdown child-reaper thread used a bare timed_join(60s); on timeout the thread stayed joinable and ~boost::thread would std::terminate. Route it through core::thread::joinOrAbandonThread so a child that refuses to die is abandoned (and the existing stuck-process check reports it) rather than crashing shutdown. The reaper blocks in waitpid(), not an interruption point, so interrupt is false. (Win32ChildProcess's pipe-reader timed_joins are intentionally left as-is: one reader writes an outer stack buffer by reference, so detaching it on timeout would be a use-after-scope -- it needs a different fix, not this mechanical migration.) Addresses #18018. * leak io_context globals so abandoned-worker exit can't run ~io_context() * address pr review: unit-test joinOrAbandonThread and minor doc/test fixes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Backport of #17822 to
rel-golden-wattle.Fixes a regression introduced by #17808, which is present on this release branch. That PR moved the PPM vulnerability download off the R main thread (addressing the startup delay in #17807), but in the rewrite it reintroduced an
isPpmIntegrationEnabled()gate on the vulnerability path -- in bothrefreshVulnerabilitiesAsync()(C++) andgetVulnerabilityRequestPlan()(R).isPpmIntegrationEnabled()is satisfied only by the Workbench-injectedPWB_PPM_*environment variables. So any session that pointsoptions(repos)at a Posit Package Manager instance by hand -- without Workbench PPM integration configured -- stopped showing vulnerability badges in the Packages pane entirely.Vulnerability display is intentionally not opt-in. This was made an explicit decision in
88778df845("always try to provide vuln info if available"), which removed an env-var gate that had been applied incidentally when the metadata column landed. The env-var gate is meant only for the Workbench-only metadata column.Changes
SessionPPM.cpp: remove theisPpmIntegrationEnabled()early-return inrefreshVulnerabilitiesAsync().SessionPPM.R: remove theisIntegrationEnabled()gate at the top ofgetVulnerabilityRequestPlan(); enablement is again driven by detecting a PPM URL ingetOption("repos")(the per-repofromRepositoryUrlcheck already in the loop). A cheap PPM-URL pre-filter is added soinstalled.packages()is still skipped for non-PPM sessions.88778df845reference).test-ppm.R: replace the now-obsolete "returns nothing when integration is disabled" test with a regression guard ("ignores the integration-enabled flag"); drop the now-deadisIntegrationEnabled()=TRUEmocks from the other plan tests.The metadata column remains gated by
isPpmMetadataColumnEnabled()exactly as before.Testing
Cherry-picked cleanly from #17822; the resulting diff is byte-identical, and the
SessionPPMfiles on this branch matchmainat the changed locations. Verified on the equivalentmainchange:cmake --build . --target rsession-- compiles and links cleanly.rstudio-tests --scope r --filter ppm--[ FAIL 0 | WARN 0 | SKIP 0 | PASS 69 ].rstudio-tests --scope rsession --filter ppm-- 231 passed, 0 failed.Notes
NEWS.mdentry: the regression was reintroduced by move PPM vulnerability download off the R main thread #17808 (2026-06-01) and has not shipped in an official release.