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

newTVar isn't properly handled in snapshots #331

Closed
barrucadu opened this issue Dec 27, 2020 · 0 comments · Fixed by #332
Closed

newTVar isn't properly handled in snapshots #331

barrucadu opened this issue Dec 27, 2020 · 0 comments · Fixed by #332

Comments

@barrucadu
Copy link
Owner

With this test case:

example0 :: Program (WithSetup (ModelTVar IO Int)) IO Int
example0 = withSetup (atomically $ newTVar 0) $ \tvar -> do
  atomically $ modifyTVar tvar (+1)
  atomically $ readTVar tvar

We get the totally nonsensical:

> putStr . unlines . map (\(a,b) -> show a ++ "     " ++ showTrace b) =<< runSCT (randomly (mkStdGen 0) 10)  defaultMemType example0                                                                       
Right 1     S0---                                                                                                                                                                                          
Right 2     S0---                                                                                                                                                                                          
Right 3     S0---                                                                                                                                                                                          
Right 4     S0---                                                                                                                                                                                          
Right 5     S0---                                                                                    
Right 6     S0---                                                                                                                                                                                          
Right 7     S0---                                                                                                                                                                                          
Right 8     S0---                                                                                                                                                                                          
Right 9     S0---                                                                                                                                                                                          
Right 10     S0---

Oh no!

The issue is that snapshots don't restore the initial value of a TVar.

I think fixing this covers up the problem in #323, but I suspect there is still an underlying bug in #323 somewhere - even if the TVar value isn't being reset correctly, it shouldn't be changing!

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

Successfully merging a pull request may close this issue.

1 participant