Fix a spaceleak with label function #93

Merged
merged 1 commit into from May 12, 2016

Conversation

Projects
None yet
2 participants
@ndmitchell
Contributor

ndmitchell commented May 7, 2016

There is a space leak with the label function. Specifically, given the following program:

{-# LANGUAGE ScopedTypeVariables #-}
import Test.QuickCheck
main :: IO ()
main = do
    Success{} <- quickCheckWithResult stdArgs{maxSuccess=10000} $ \(p :: Double) -> label "foo" True
    print "done"

Running it I get:

$ ghc --make Main.hs -rtsopts && Main +RTS -K1K
...
Linking Main.exe ...
Main: Stack space overflow: current size 33624 bytes.
Main: Use `+RTS -Ksize -RTS' to increase it.

The -K1K flag limits the stack, which makes it easier to detect the space leak. Under normal circumstances it just increases memory usage and makes things go unnecessarily slower without failing.

After applying the patch the space leak disappears. Originally spotted by @jacereda and reported at ndmitchell/shake#450.

@ndmitchell ndmitchell referenced this pull request in ndmitchell/shake May 7, 2016

Closed

Space leak in QuickCheck test #450

@nick8325 nick8325 merged commit 885d430 into nick8325:master May 12, 2016

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
@nick8325

This comment has been minimized.

Show comment
Hide comment
@nick8325

nick8325 May 12, 2016

Owner

Thanks!

Owner

nick8325 commented May 12, 2016

Thanks!

@ndmitchell

This comment has been minimized.

Show comment
Hide comment
@ndmitchell

ndmitchell May 22, 2016

Contributor

For info (mostly for those who stumble upon this in future) I wrote up some of the details in a blog post: http://neilmitchell.blogspot.co.uk/2016/05/another-space-leak-quickcheck-edition.html

Contributor

ndmitchell commented May 22, 2016

For info (mostly for those who stumble upon this in future) I wrote up some of the details in a blog post: http://neilmitchell.blogspot.co.uk/2016/05/another-space-leak-quickcheck-edition.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment