Skip to content

Mysterious hang when using tasty with hedgehog and IO #449

@newhoggy

Description

@newhoggy

When using tasty to run a hedgehog property that does simple IO (for example reading a file), the process can occasionally hang indefinitely.

The code for reproducing the hang can be found here: https://github.com/newhoggy/tasty-hang

The reproducer contains three executables:

  • tasty-hang-bad - This executable uses tasty to invoke a hedgehog property that has withTests 1 and no generators, which effectively makes it a unit test. The test reads a small file. This can hang when run often enough.
  • tasty-hang-good - This executable uses hunit instead of hedgehog to read a small file. This has not been observed to hang.
  • tasty-hang-none - This executable invokes hedgehog directly form IO without using tasty at all. This has not been observed to hang.

I am running on Linux on WSL2 on Windows. The CPU has 32 cores.

To reproduce, I create a script file like this:

((date >&2; for x in {0..99999}; do echo "== $x =="; echo "== $x ==" >&2; tasty-hang-none; done) > ../stdout-1.log 2> ../stderr-1.log)
((date >&2; for x in {0..99999}; do echo "== $x =="; echo "== $x ==" >&2; tasty-hang-none; done) > ../stdout-2.log 2> ../stderr-2.log)
((date >&2; for x in {0..99999}; do echo "== $x =="; echo "== $x ==" >&2; tasty-hang-none; done) > ../stdout-3.log 2> ../stderr-3.log)
((date >&2; for x in {0..99999}; do echo "== $x =="; echo "== $x ==" >&2; tasty-hang-none; done) > ../stdout-4.log 2> ../stderr-4.log)
((date >&2; for x in {0..99999}; do echo "== $x =="; echo "== $x ==" >&2; tasty-hang-none; done) > ../stdout-5.log 2> ../stderr-5.log)
((date >&2; for x in {0..99999}; do echo "== $x =="; echo "== $x ==" >&2; tasty-hang-none; done) > ../stdout-6.log 2> ../stderr-6.log)
((date >&2; for x in {0..99999}; do echo "== $x =="; echo "== $x ==" >&2; tasty-hang-none; done) > ../stdout-7.log 2> ../stderr-7.log)
((date >&2; for x in {0..99999}; do echo "== $x =="; echo "== $x ==" >&2; tasty-hang-none; done) > ../stdout-8.log 2> ../stderr-8.log)

Then I run each loop concurrently like this:

cat script.sh | parallel

Then, in another terminal, I watch the progress of the run like this:

watch ls -la stdout-*.log

If any of the log files stop growing before the others, the associate process has hung.

This issue has been raised with hedgehog as well: hedgehogqa/haskell-hedgehog#547

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions