typelead / eta-hackage

A set of patches to make Hackage compatible with the Eta language.
64 stars 31 forks source link

bytestring (lazy) readFile not working properly #54

Closed rpeszek closed 7 years ago

rpeszek commented 7 years ago

The file is read

import qualified Data.ByteString.Lazy as LBS
    ...
      myLBS <- LBS.readFile "some file"

but doing anything with the bytestring results in error at some point. I can print the bytestream but stack traces will print afterwords. Trying something like this:

LBS.length myLBS

will exception immediatelly The error looks like this:

Caused by: eta.runtime.exception.EtaException: Exception was thrown in rendering exception of type class java.lang.NullPointerException
    at base.foreign.c.Error$throwErrnoIfMinus1RetryMayBlock2.enter(Unknown Source)
    at base.ghc.io.FD$$wa5.enter(Unknown Source)
    at base.ghc.io.handle.Text$sat_sGLFS.enter(Unknown Source)
    at eta.runtime.apply.Function.applyPV(Function.java:120)
    at base.ghc.io.handle.Internals$wantReadableHandle2.enter(Unknown Source)
    at base.ghc.io.handle.Internals$sat_sG0K9.enter(Unknown Source)
    at eta.runtime.apply.PAP.apply(PAP.java:31)
    at eta.runtime.apply.PAP.applyV(PAP.java:41)
    at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
    at eta.runtime.exception.Exception.catch_(Exception.java:136)

Corresponding code works fine if compiled and executed with stack.

Example code reproducing the issue: https://github.com/rpeszek/eta-misc-test/tree/eta-hackage-issue-54

I am at current head commit on eta master 1dbe87b19f815ba12ec33f558cb7b572a74e03c1

rahulmutt commented 7 years ago

Thanks for reporting this! It turns out that is not really a bytestring problem, but a problem with readFile in general (the one from base).

rahulmutt commented 7 years ago

Fixed on master. Try it out and re-open this issue if it doesn't work.