Skip to content

Fix concurrency issue in Eval plugin #2303

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ghcide/src/Development/IDE/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ import GHC.IO.Handle (hDuplicate)
import HIE.Bios.Cradle (findCradle)
import qualified HieDb.Run as HieDb
import Ide.Plugin.Config (CheckParents (NeverCheck),
Config,
Config, checkParents,
checkProject,
getConfigFromNotification)
import Ide.Plugin.ConfigUtils (pluginsToDefaultConfig,
pluginsToVSCodeExtensionSchema)
Expand Down Expand Up @@ -193,7 +194,10 @@ defaultArguments priority = Arguments
, argsGhcidePlugin = mempty
, argsHlsPlugins = pluginDescToIdePlugins Ghcide.descriptors
, argsSessionLoadingOptions = def
, argsIdeOptions = const defaultIdeOptions
, argsIdeOptions = \config ghcSession -> (defaultIdeOptions ghcSession)
{ optCheckProject = pure $ checkProject config
, optCheckParents = pure $ checkParents config
}
, argsLspOptions = def {LSP.completionTriggerCharacters = Just "."}
, argsDefaultHlsConfig = def
, argsGetHieDbLoc = getHieDbLoc
Expand Down
12 changes: 11 additions & 1 deletion plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ import UnliftIO.Temporary (withSystemTempFile)
import GHC.Driver.Session (unitDatabases, unitState)
import GHC.Types.SrcLoc (UnhelpfulSpanReason (UnhelpfulInteractive))
#else
import Control.Concurrent.MVar
import DynFlags
import HscTypes (HscEnv (hsc_dynLinker))
import LinkerTypes (DynLinker (..))
#endif


Expand Down Expand Up @@ -556,7 +559,14 @@ runGetSession st nfp = liftIO $ runAction "eval" st $ do
let fp = fromNormalizedFilePath nfp
((_, res),_) <- liftIO $ loadSessionFun fp
let hscEnv = fromMaybe (error $ "Unknown file: " <> fp) res
ghcSessionDepsDefinition hscEnv nfp
hscEnvWithDeps <- ghcSessionDepsDefinition hscEnv nfp
-- duplicate the linker since it is mutable and therefore not multi-threaded
duplicateDynLinker hscEnvWithDeps

duplicateDynLinker :: MonadIO m => HscEnv -> m HscEnv
duplicateDynLinker hsc = do
newLinker <- liftIO $ newMVar =<< readMVar (dl_mpls $ hsc_dynLinker hsc)
return hsc{ hsc_dynLinker = DynLinker newLinker}

needsQuickCheck :: [(Section, Test)] -> Bool
needsQuickCheck = any (isProperty . snd)
Expand Down