Commit Graph

173 Commits

Author SHA1 Message Date
Michael Walker
1c2bba5050
Bump tasty upper bound to <1.6 2023-09-11 19:56:10 +01:00
Michael Walker
42fa864e39
Remove vendored tasty-hedgehog 2023-06-18 01:34:48 +01:00
Michael Walker
a33560db15
Fix test compilation errors with latest deps
I'm going to drop support for GHC 8.0, which'll mean I can also drop
this janky vendored tasty-hedgehog.
2023-06-17 22:42:19 +01:00
Michael Walker
62ea188711
Fix lint failure 2022-11-26 23:04:04 +00:00
Michael Walker
11ccf950e7 Add LTS-19.0 to build matrix & supported GHC versions doc
There should be a patch release of dejafu after this, since the
doctest examples changed.

Also, need to bump to a nightly snapshot in `stack.yaml` for
stylish-haskell, which looks to have skipped GHC 9.0 support.

In principle, we could now drop support for GHC 8.0, 8.2, and 8.4, but
supporting those isn't causing any problems yet.
2022-08-22 14:40:35 +01:00
Michael Walker
ac0221c1da Fix various compiler warnings
There are still others remaining, but they can't all be fixed if I
want to keep compatibility with older GHC versions.
2021-03-14 00:11:23 +00:00
Michael Walker
2294663de8 Fix Par Monad example test failure
With the ParMonad / "testing exposes a deadlock" / randomly test,
simplification threw an error:

    Exception: (dejafu) Got a different result after simplifying:
    'True' /= 'Abort'

This is failing even with previously supported versions of GHC, so I
think it's a new library version (probably random, giving an original
trace which exposes the bug).

Disabling "safe IO" for this test fixes it, which means that either
the IO is not safe after all, or that there's another bug elsewhere
which is being hidden now that simplification is more
restricted... however, none of the other tests are failing, so I hope
it's just the IO.
2021-03-14 00:11:23 +00:00
Michael Walker
700fb5f1c4 Remove use of . in dejafu-tests (fix for GHC 9.0)
Like the use of `const` in concurrency and dejafu, this doesn't play
nicely with higher ranked types.
2021-03-14 00:11:23 +00:00
Michael Walker
86dde99f52 Correctly reset new TVar values when restoring snapshots
This adds the overhead of constructing the effect to every STM
transaction, which I worried would be a large cost; but it turns out
that the overhead is negligible.
2020-12-28 00:04:28 +00:00
Michael Walker
e166641b59 Add a failing test for #331 2020-12-28 00:00:49 +00:00
Michael Walker
cfa86a8baa Make dejafu-tests benchmarks compatible with tasty-1.4
The `opts` param is now passed to `T.foldGroup`, but I don't need it.
2020-12-27 22:12:06 +00:00
Michael Walker
75eac6693f Remove Bool from Throw/ThrowTo/ThrownSTM actions
If the Maybe MaskingState is Just, then the thread survived; if it's
Nothing the thread was killed.
2020-07-01 00:29:37 +01:00
Michael Walker
9601a78cef Add a ThrownSTM thread action
This is for transactions which throw an exception, rather than
stuffing that information into the `STM` action.  This makes the
traces a bit clearer (eg, you can now tell without needing to inspect
the STM trace if an exception was thrown by a transaction).

I've called this "ThrownSTM" rather than "ThrowSTM" because it's like
"BlockedSTM" (just another failure case), and that's also past tense.
2020-07-01 00:29:37 +01:00
Michael Walker
601c4c8690 Atomically update masking state on jumping to an exc. handler
In this excerpt:

    uninterruptibleMask $ \restore -> fork $ do
      result <- try (restore (throw ThreadKilled))
      ...

The `throw` jumps to an exception handler registered outside the
`restore`, which means there is a masking state change.  Previously,
dejafu handled this by inserting an `AResetMask` action as the first
action of the handler; but this is incorrect, as it opens a potential
race condition with another thread calling `throwTo`.  As `throw` (and
`throwTo`, and an uncaught `throwSTM`) "use up" the exception handler,
this is not a benign race: the thread will be killed!

The solution is to atomically restore the masking state.

This commit implements that, and changes `Throw`, `ThrowTo`, and `STM`
to include the new masking state (if it changed).  I think this is a
bit confusing, so I'll make a follow-up commit to split out a new
`ThrownSTM` action.
2020-07-01 00:29:36 +01:00
Michael Walker
6d74a8977a Add failing tests for #324 2020-07-01 00:29:07 +01:00
Michael Walker
414554d1ef Add unsafeUnmask to dejafu 2020-05-14 13:50:12 +01:00
Michael Walker
be312a0f46 Add getMaskingState to dejafu 2020-05-10 23:05:07 +01:00
Michael Walker
f21d4ead86 Fix lints 2020-05-10 21:22:30 +01:00
Michael Walker
03f0e63b8b Fix new lints
There is a change to 'concurrency' here, but I don't think it's worth
making even a patch release.
2020-02-20 22:54:12 +00:00
Michael Walker
cef95c83c8 Get dejafu-tests building with hedgehog-1.0.2
tasty-hedgehog is now in stackage, so it would be great to use that;
but it's not in *older* stackages, hmm...
2020-02-20 22:13:48 +00:00
Michael Walker
0046a2b6e0 Fix hedgehog-1.0.0 test compilation failures 2019-10-04 18:21:50 +01:00
Michael Walker
ab5daf1509 Fix GHC 8.8 test compilation failures 2019-10-04 18:21:50 +01:00
Michael Walker
7b72e28544 Add some tests for MonadDejaFu IO & ST 2019-03-24 02:29:43 +00:00
Michael Walker
626ce585d3 Add failing test for #267 2019-03-14 11:20:37 +00:00
Michael Walker
cb118e4f41 Use the post-withSetup DepState
It's wrong to use initialDepState when there is a setup action, as the
action could end with a DepState which is not the same as the initial
one.  Here's an example of it going wrong:

    > :{
    resultsSet defaultWay defaultMemType $ do
      v <- newMVar ()
      fork (takeMVar v)
      readMVar v
    :}
    fromList [Left Deadlock,Right ()]

    > :{
    resultsSet defaultWay defaultMemType $
      withSetup (newMVar ()) $ \v -> do
        fork (takeMVar v)
        readMVar v
    :}
    fromList [Right ()]

This PR pushes responsibility for the DepState into the Context, and
the DepState is passed to all schedulers.  That means it's been
promoted from an internal type to a user-facing one, so I gave it the
more generic name "ConcurrencyState".  Furthermore, the snapshotted
DepState is passed to all the DPOR functions, and the trace
simplification functions.

initialDepState is now only used:

- in Conc.Internal to initialise a new context
- in SCT.Internal when there is no snapshot
2019-02-12 22:20:34 +00:00
Michael Walker
0a1543ef6b Uncomment AutoUpdate deadlock test 2019-02-12 18:13:42 +00:00
Michael Walker
129c21912e Implement effect-free concurrency invariants 2019-02-02 18:33:17 +00:00
Michael Walker
da474b5dcf Turn 'Program' typeclass into a GADT
With careful application of typeclass instances to this GADT, and by
redefining 'ConcT' in terms of it, this solves the type inference
problem and removes the need for the 'basic' function.  This approach
also has less newtype wrapping/unwrapping, and so is probably a step
in the right direction even without the type inference advantages.

The diff is quite big because things have needed to migrate between
modules to avoid the import graph getting even worse.
2019-02-02 01:38:39 +00:00
Michael Walker
1b048d4453 Remove Deadlock / STMDeadlock distinction 2019-02-02 01:38:39 +00:00
Michael Walker
68ed444589 Make length bounding work for random scheduling too
This works by pulling the LengthBound out of the Bounds.  A logical
extension of this would be to do away with Bounds entirely, and make
PreemptionBound and FairBound settings in their own right, but as they
only apply to DPOR, keeping them coupled to it feels less misleading.
2019-02-02 01:38:39 +00:00
Michael Walker
d375387784 Replace dontCheck/subconcurrency with new Program class
The 'Program' is the new formulation of dejafu unit tests.  A
'Program' is one of three types:

- A 'ConcT', which is as before.

- A 'WithSetup', which corresponds to 'dontCheck'.

- A 'WithSetupAndTeardown', which corresponds to 'subconcurrency'.

This more new formulation makes it impossible to nest 'withSetup' (the
replacement for 'dontCheck') or 'withSetupAndTeardown' (the
half-replacement for 'subconcurrency'), by as these functions take a
'ConcT' as their argument and produce a 'Program WithSetup' or
'Program WithSetupAndTeardown'.

The testing functions have all been generalised to work with this
'Program' type.
2019-02-02 01:38:39 +00:00
Michael Walker
ac35055beb Remove unnecessary CPP 2019-02-01 23:14:31 +00:00
Michael Walker
c17f66303a Remove deprecated functions & types 2019-01-20 14:24:46 +00:00
Michael Walker
798acc0894 Add 'lshowAborts', to make SCT functions show (now hidden) aborts 2019-01-20 00:07:17 +00:00
Michael Walker
02467da2ac Rename Failure to Condition 2019-01-20 00:07:17 +00:00
Michael Walker
07cb9f43e7 Turn internal errors into exceptions 2019-01-18 21:56:33 +00:00
Pepe Iborra
3f1f775bd7 Fix warnings 2018-12-01 10:14:11 +00:00
Pepe Iborra
44c9dfbe1c Fix incomplete pattern matches to avoid a MonadFail constraint 2018-11-26 22:00:40 +00:00
Michael Walker
65ac6ab18b Track how many buffered writes an IORef has 2018-07-15 11:32:28 +01:00
Michael Walker
039295ef41 Rename CRef to IORef 2018-07-01 12:45:43 +01:00
Michael Walker
38ee90cee8 Turn all tests into benchmarks 2018-06-24 11:34:31 +01:00
Michael Walker
ccb4b9aa24 Split up dejafu-tests main 2018-06-24 11:29:02 +01:00
Michael Walker
ec11aa7baf Enable systemtic par monad test 2018-06-17 13:28:50 +01:00
Michael Walker
92c8d941e7 Do not consider safe IO dependent 2018-06-17 12:49:15 +01:00
Michael Walker
118d7780a6 Fix hlint errors 2018-06-17 11:21:43 +01:00
Michael Walker
f263166a45 Invert the predicate in notAlwaysSame
I think having `alwaysSameBy f` and `notAlwaysSameBy f` be inverse of
each other is better than `notAlwaysSameBy (\a b -> not (f a b))`.
2018-06-10 22:30:02 +01:00
Michael Walker
54d64a16b4 Add predicate unit tests 2018-06-10 22:30:02 +01:00
Michael Walker
d0f23f5818 Reject failures in alwaysSame/On/By 2018-06-10 14:28:49 +01:00
Michael Walker
73ff73b544 Add a couple of tests for inherited masking states
Closes #207
2018-06-10 03:29:50 +01:00
Michael Walker
a54813926e Remove very slow parmonad test
It's unfortunate, but this one test is causing travis to frequently
time out.
2018-06-10 01:42:35 +01:00