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

Using the GHC API on Mac OS X with ghci or runhaskell causes a segmentation fault #11

Closed
kazu-yamamoto opened this issue Jan 9, 2012 · 23 comments

Comments

@kazu-yamamoto
Copy link
Collaborator

If docTest is used with ghci or runghc, it causes segfault:

*Main> docTest ["../Data/RBTree.hs"] ["-i.."]
zsh: segmentation fault ghci Test2.hs

This is very inconvenient because "runghc Test.hs", for exmaple causes segfault, where
Test.hs contains test-framework-doctest.

Are there any work around on this?

I'm using GHC 7.0.4 on Mac.

@sol
Copy link
Owner

sol commented Jan 9, 2012

I'm not aware of that issue. Does the doctest test suite run flawlessly on your system? Say, the following reports no errors:

cabal configure && cabal build && ./tests/runtests.sh

@sol
Copy link
Owner

sol commented Jan 9, 2012

Btw, thx for reporting this!

@kazu-yamamoto
Copy link
Collaborator Author

No errors were reported with runtests.sh. In my environement, compiled "Test.hs" can work well.

@kazu-yamamoto
Copy link
Collaborator Author

BTW. My plan is to integrate doctest to test-framework-th. I have already implemented it and doctest really enpowers test-framework. I will release the package in this week. Thank you for your work on doctest!

@sol
Copy link
Owner

sol commented Jan 9, 2012

I think it is critical to make this work with runhaskell. I can not reproduce this on Linux (with GHC 7.0.4). I think it would be nice if we'd have a test case, that provokes this error. Can you try if runhaskell tests/Main.hs from the test-framework-doctest repository provokes this on your system?

Btw: Have you tried with doctest HEAD, or only with the latest release?

@kazu-yamamoto
Copy link
Collaborator Author

I tested both on Linux Mac:

---- 0.4.2 HEAD
Linux OK OK
Mac NG NG

NG means bus error or seg fault or "Too late for parseStaticFlags: call it before newSession".

I guess this bug is specific to Mac.

@kazu-yamamoto
Copy link
Collaborator Author

I forgot to write what I did:

Prelude> :m Test.DocTest
Prelude Test.DocTest> getDocTests [] ["Data/RBTree.hs"]

@kazu-yamamoto
Copy link
Collaborator Author

We can forget test-framework-doctest. Let's just think about doctest.

@sol
Copy link
Owner

sol commented Jan 10, 2012

The "Too late for parseStaticFlags: call it before newSession" issue is a limitation of GHC (yes, GHC uses global state, see the code, if you are inclined). You can only run getDocTests once per process. So you have to start a new ghci session after a call to getDocTests. This is why I recommend to test this with runhaskell only.

Maybe you are affected by GHC bug #5031/#5132. Can you try one of the minimal test cases given in the tickets?

@kazu-yamamoto
Copy link
Collaborator Author

Thank you for your info.

Due to this bug, I cannot install GHC 7.4.0 on my Mac at this moment.

http://hackage.haskell.org/trac/ghc/ticket/5726

@sol
Copy link
Owner

sol commented Jan 11, 2012

Can you verify that test-framework-doctest works with runhaskell once http://hackage.haskell.org/trac/ghc/ticket/5726 gets fixed? In that case I'd leave the ticket open until we have checked that.

@kazu-yamamoto
Copy link
Collaborator Author

I keep this issue in mind. I will try this with GHC RC2.

@sol
Copy link
Owner

sol commented Feb 2, 2012

@kazu-yamamoto any new findings on that?

@kazu-yamamoto
Copy link
Collaborator Author

Good timing. I have tried GHC 7.4.0 rc2 just before but many packages including doctest and xhtml limit version of "base" and "ghc". I was tiered to fix them and stopped this confirm job...

@sol
Copy link
Owner

sol commented Mar 26, 2012

@kazu-yamamoto Awesome! I saw you adapted test-framework-doctest to the latest version of Doctest.

Have you tested this with runhaskell/ghci and ghc-7.4.1?

@kazu-yamamoto
Copy link
Collaborator Author

Thank you for reminding. Now I can install all related packages. Unfortunately, runghc generated the following error:

lookupSymbol failed in relocateSection (relocate external)
/Users/kazu/Library/Haskell/ghc-7.4.0.20120126/lib/doctest-0.6.0/lib/HSdoctest-0.6.0.o: unknown symbol _doctestzm0zi6zi0_Pathszudoctest_version1_closure' Set.hs: Set.hs: unable to load packagedoctest-0.6.0'

If I use ghc to compile, the test program works well. Any thoughts?

@sol
Copy link
Owner

sol commented Mar 26, 2012

Yes, the library section in the cabal file probably does not list all modules. I'll fix that, and do a maintenance release.

@kazu-yamamoto
Copy link
Collaborator Author

I will test this with GHC 7.4.1.

http://hackage.haskell.org/trac/ghc/ticket/5748

@sol
Copy link
Owner

sol commented Mar 26, 2012

@kazu-yamamoto Ok, done.

Can you test with the latest version?

cabal update && cabal install doctest

@sol
Copy link
Owner

sol commented Mar 26, 2012

Hmm, I think it would be nice to require that version in the cabal file of test-framework-doctest. Does checking for patch versions work in cabal files? If not, I'd do an other release as 0.6.1.

@kazu-yamamoto
Copy link
Collaborator Author

Bravo! runghc 7.4.1 works well with doctest 0.6.0.1!

@kazu-yamamoto
Copy link
Collaborator Author

I tested with test-framework-doctest which includes my patch exactly.

@sol
Copy link
Owner

sol commented Mar 26, 2012

Ok, I think we can finally close this ticket.

@sol sol closed this as completed Mar 26, 2012
gelisam added a commit to gelisam/hawk that referenced this issue Jan 5, 2014
Using the doctest library currently causes the tests to fail with the
following message:

  reference: Too late for parseStaticFlags: call it before newSession

There used to be an issue with that error message in an old version of
ghc [1], not sure why we are triggering it again with a recent version.
Regardless, the workaround is easy: use the executable version of
doctest instead of the library version.

[1] sol/doctest#11
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

No branches or pull requests

2 participants