Skip to content
  • Thomas Miedema's avatar
    Fix ghc-pkg reports cache out date (#10205) · f0636562
    Thomas Miedema authored
    See Note [writeAtomic leaky abstraction].
    
    GHC on Linux already received a patch for this bug in
    e0801a0f. On Windows several cabal tests
    were hitting the bug, causing validate failures, but we never noticed
    because of all the other tests that were failing on Windows. And it
    didn't start happening till `getModificationTime` received sub-second
    resolution support on Windows in
    5cf76186.
    
    Since there are regression tests already, I am not adding another one.
    But for good measure, here is a script that shows the bug without
    needing to do a full validate run:
    
      DB=/tmp/package.conf.d.test
      GHC_PKG=ghc-pkg #utils/ghc-pkg/dist/build/tmp/ghc-pkg
      LOCAL_GHC_PKG="${GHC_PKG} --no-user-package-db --global-package-db=${DB}"
      while true; do
        rm -rf ${DB}
        ${LOCAL_GHC_PKG} init "${DB}"
        ${LOCAL_GHC_PKG} list
      done
    
    If you see "WARNING: cache is out of date" after a few seconds, the bug
    is not fixed.
    
    Reviewed By: austin
    
    Differential Revision: https://phabricator.haskell.org/D990
    
    GHC Trac Issues: #10205
    f0636562