Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extremely rare case of infinite send lost signals if thread restarted by SIGQUIT after restart signal is lost #657

Open
ivmai opened this issue Aug 27, 2024 · 1 comment

Comments

@ivmai
Copy link
Owner

ivmai commented Aug 27, 2024

Source: master (02c9d85)

This is follow up of #630, #633.
As mentioned in the code

/* FIXME: Still, an extremely low chance exists that the */

  STATIC int GC_restart_all(void)
  {
    int n_live_threads = 0;
    ...
          if (GC_retry_signals
                && AO_load(&(p -> last_stop_count)) == GC_stop_count) {
            /* The thread has been restarted.   */
            if (!in_resend_restart_signals) {
              /* ... */
            } else {
              continue;
              /* FIXME: Still, an extremely low chance exists that the  */
              /* user signal restarts the thread after the restart      */
              /* signal has been lost (causing sem_timedwait() to fail) */
              /* while retrying, causing finally a mismatch between     */
              /* GC_suspend_ack_sem and n_live_threads.                 */
            }
          }
          n_live_threads++;
          ...

The probability of this is extremely low (probably never observed in practice).

@ivmai
Copy link
Owner Author

ivmai commented Aug 27, 2024

I think to fix this properly we should replace n_live_threads counter with a flag in GC_thread indicating that sem_[timed]wait() should be called to "compensate" sem_post() call done in the given thread.

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

No branches or pull requests

1 participant