While testing Splint on some larger projects, I noticed I could reliably get a crash if I ran GHC with -j. Eventually I tracked the problem down to the call to argsSettings. This made me discover two bugs:
Multiple threads could attempt to load the settings at the same time. If both threads started at about the same time, they would both see an empty settings value and then try to load the settings. The fix here was to introduce the RemoteData type with an explicit Loading constructor. If any other threads are currently loading the settings, they won't get fetched again.
Each file can set its own command-line options using {-# OPTIONS_GHC -fplugin-opt=Splint:whatever #-}. Since there was only one settings value, every file was forced to use the same settings. The fix here was to make a Map of settings, keyed on the options.
This PR fixes the crash, prevents two threads from loading the same settings at the same time, and allows files to use different settings.
While testing Splint on some larger projects, I noticed I could reliably get a crash if I ran GHC with
-j
. Eventually I tracked the problem down to the call toargsSettings
. This made me discover two bugs:Multiple threads could attempt to load the settings at the same time. If both threads started at about the same time, they would both see an empty settings value and then try to load the settings. The fix here was to introduce the
RemoteData
type with an explicitLoading
constructor. If any other threads are currently loading the settings, they won't get fetched again.Each file can set its own command-line options using
{-# OPTIONS_GHC -fplugin-opt=Splint:whatever #-}
. Since there was only one settings value, every file was forced to use the same settings. The fix here was to make aMap
of settings, keyed on the options.This PR fixes the crash, prevents two threads from loading the same settings at the same time, and allows files to use different settings.