Skip to content

Synchronize completion cache updates with ALPM handle lifetime#2811

Draft
Copilot wants to merge 3 commits intonextfrom
copilot/fix-sigsegv-completion-cache-race
Draft

Synchronize completion cache updates with ALPM handle lifetime#2811
Copilot wants to merge 3 commits intonextfrom
copilot/fix-sigsegv-completion-cache-race

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

yay -Syu could crash after a successful transaction when the completion cache refresh was still traversing sync databases while the main flow released the shared ALPM handle. The race was caused by a fire-and-forget goroutine in OperationService.Run with no synchronization before cleanup.

  • Serialize completion cache teardown with command teardown

    • Extract the completion refresh launch into a small helper that returns a wait function.
    • Start the refresh asynchronously as before, but defer the wait in OperationService.Run so the method does not return until the cache update is done.
    • This keeps the existing background behavior while ensuring main() cannot reach dbExecutor.Cleanup() early.
  • Add focused coverage for the synchronization point

    • Add unit tests for the helper to verify:
      • no background work starts when the cache is fresh
      • the returned wait function blocks until the background refresh completes
  • Representative change

    waitForCompletionUpdate := o.startCompletionUpdate(ctx, run)
    if waitForCompletionUpdate != nil {
        defer waitForCompletionUpdate()
    }

Copilot AI changed the title [WIP] Fix SIGSEGV crash during yay -Syu operation Synchronize completion cache updates with ALPM handle lifetime Apr 2, 2026
Copilot AI requested a review from Jguer April 2, 2026 12:44
Copilot finished work on behalf of Jguer April 2, 2026 12:44
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.

SIGSEGV: completion cache goroutine races with ALPM handle cleanup

2 participants