Skip to content
  • Ben Gamari's avatar
    rts: Close livelock window due to rapid ticker enable/disable · 16a51a6c
    Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
    This fixes #11830, where the RTS would livelock if run with `-I0` due
    to a regression introduced by bbdc52f3.
    The reason for this is that the new codepath introduced a subtle race
    condition:
    
     1. one thread could request that the ticker stop and would block until
        the ticker in fact stopped
     2. meanwhile, another thread could sneak in and restart the ticker
    
    this was implemented in such a way where thread (1) would end up
    blocked forever. The solution here is to simply not block. The worst
    that will happen is that timer fires again, but is ignored since the
    ticker is stopped.
    
    Test Plan:
    Validate, try reproduction case in #11830. Need to find a nice
    testcase.
    
    Reviewers: simonmar, erikd, hsyl20, austin
    
    Reviewed By: erikd, hsyl20
    
    Subscribers: erikd, thomie
    
    Differential Revision: https://phabricator.haskell.org/D2129
    
    GHC Trac Issues: #11830
    16a51a6c