You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sydTest (and most related functions, such as sydTestResults, ...) cannot be run twice in a concurrent environment because they internally relies on non thread safe features.
Since this library is built on top of the curses interface, it is not thread-safe.
The following code will hence hapilly segfault:
importTest.Syd
main = sydTest $do
it "test 1"$do
sydTest $ it "inner"$1`shouldBe`1
it "test 2"$do
sydTest $ it "inner"$1`shouldBe`1
Built with -O2 -threaded and run with --continuous +RTS -N and you'll eventually get a segfault.
This is not a problem in traditionnal uses of sydtest, however, it is a problem when using sydtest in the sydtest test suite itself. That's what I tried when working on #80 (especially, see comment #80 (comment)).
Note that a workaround is to use "internal" functions which does not do the detection, such as:
I wanted to track in a ticket that sydTest cannot be run concurrently, so if someone hit a segmentation fault, maybe they'll find this ticket. I'm unsure sydtest should be fixed (e.g. the fix would be highly invasive and complex), however maybe the documentation may list the "unsafe" functions.
The text was updated successfully, but these errors were encountered:
guibou
changed the title
Multiples sydTest cannot be called in parallel
Multiples sydTest segfault in parallel
Aug 14, 2024
This closesNorfairKing#91 by avoiding
a call to `withArgs` if the argument list is already empty.
`withArgs` can crash in a concurrent environment (see GHC BUG
https://gitlab.haskell.org/ghc/ghc/-/issues/18261), hence we reduce the
chance of this happening by not calling it when the list of arguments is
already in the required state (e.g. empty).
sydTest
(and most related functions, such assydTestResults
, ...) cannot be run twice in a concurrent environment because they internally relies on non thread safe features.Especially (but maybe not exhaustive):
withArgs
, which is not thread-safe according to https://gitlab.haskell.org/ghc/ghc/-/issues/18261The following code will hence hapilly segfault:
Built with
-O2 -threaded
and run with--continuous +RTS -N
and you'll eventually get a segfault.This is not a problem in traditionnal uses of sydtest, however, it is a problem when using sydtest in the sydtest test suite itself. That's what I tried when working on #80 (especially, see comment #80 (comment)).
Note that a workaround is to use "internal" functions which does not do the detection, such as:
I wanted to track in a ticket that sydTest cannot be run concurrently, so if someone hit a segmentation fault, maybe they'll find this ticket. I'm unsure sydtest should be fixed (e.g. the fix would be highly invasive and complex), however maybe the documentation may list the "unsafe" functions.
The text was updated successfully, but these errors were encountered: