Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • G gnome-keyring
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 94
    • Issues 94
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • gnome-keyring
  • Merge requests
  • !12

test-gkd-ssh-agent-service: Avoid race condition with server thread

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Simon McVittie requested to merge smcv/gnome-keyring:test-gkd-ssh-agent-service-race into master Mar 09, 2019
  • Overview 1
  • Commits 1
  • Pipelines 1
  • Changes 1

These tests create a server thread in setup() and join it in teardown(), but there are various race conditions between them that can cause the test to hang. These are particularly reproducible when building on a single-CPU machine or VM, and particularly in the startup_shutdown test (which doesn't do anything, so it runs teardown() immediately after setup()).

It's possible to get this preemption pattern:

 ___ Main thread ___                ___ Server thread ___
 g_thread_new()                     (starts)
 g_cond_wait() (blocks)
                                    ...
                                    g_cond_signal()
                                    (gets preempted here)
 exit setup()
 enter teardown()
 g_main_loop_quit()
                                    g_main_loop_run()

which means g_main_loop_run() will never terminate, because it wasn't running yet when the main thread told the GMainLoop to quit, and the main thread won't tell it to quit again.

One way to solve this would be for the server thread to signal test->cond from an idle callback instead of directly from server_thread(), to guarantee that the GMainLoop is already running. However, it seems easier to reason about if we avoid GMainLoop and iterate the main context directly.

Debian bug #909416

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: test-gkd-ssh-agent-service-race