[jhc] bugs/issues in jhc-0.7.6‏

John Meacham john at repetae.net
Sun Aug 8 21:23:38 EDT 2010

On Sat, Aug 07, 2010 at 11:27:10AM +0000, Korcan Hussein wrote:
> Hello, I just wanted to report some bugs & issues with jhc using SDL
> bindings (https://patch-tag.com/r/snk_kid) I've put links to the
> original Haskell code and generated C (which was outputted from
> compile-time error) at the end of this email.

Thanks for the report! I'll look into these. One of the main thing jhc
needs right now is people actually attempting to use it and reporting
their experiences :)

> C Compile-time errors:
> This one comes up quite lot, and happens quite randomly:
> test_code.c:4136: error: ‘v74’ undeclared (first use in this function)
> ...
> Sometimes it goes away just by shuffling some code, even just
> commenting a line and uncomment it again can make it go away but it
> happens a lot and sometimes it's really hard to make it go for a long
> period of time. The problem is there is a function called but the
> argument given is not defined in the scope it's used in.

Hmmm.. I have noticed this too on occasion, A problem is that it is a
general symptom of bugs in pretty much any grin transformation, I
actualyl fixed a major one that was causing this issue in 0.7.6. I
believe I need to improve the grin linter (Grin.Lint) to catch these bugs
as they occur to get better diagnostic info. Once I narrow it down to a
specifc pass and dump before and after code, it is usually easy to find
issues like this.

> test_code.c:5182: error: expected expression before ‘;’ token
> test_code.c: In function ‘fW$__fInstance$__iForeign_Storable_pokeByteOff_default’:
> This is caused by the code generated for the "whileEvents" in the Haskell source I've attached. It just generates incorrect C code, like it was a serious failure.
> jhc issues:
> The action "pollEvent" defined as:
> foreign import ccall "SDL_PollEvent" sdlPollEvent :: Ptr Event -> IO Int
> -- | Polls for currently pending events.
> pollEvent :: IO Event
> pollEvent 
>     = alloca poll
>     where poll ptr
>               = do ret <- sdlPollEvent ptr
>                    case ret of
>                      0 -> return NoEvent
>                      _ -> do event <- peek ptr
>                              case event of
>                                NoEvent -> poll ptr
>                                _ -> return event
> When used, while compiling with jhc, when it reaches the compile stage "-- Boxy WorkWrap" jhc consumes a lot of memory and takes a large amount time to finish.
> Next jhc crashed with the message:
> "jhc: internal error: evacuate: strange closure type 65350"
yikes. that means it is hitting a ghc bug, actually ghc behaves
strangely sometimes when pushed too far, so it is likely a resource bug
in jhc that is triggering it.

> This happened using the loop function and cross-compiling.
> Program Runtime issues:
> When you do get this code to compile (by not using the loop function,
> use delay), if you comment out the lines I've marked there is a bug
> where (foreign) pointers in the same scope some how overwrite the
> values of previously defined pointers even though there is no
> re-assignment going on so they end up all being the same address
> value, this code works correctly in ghc. I haven't checked this yet
> but it feels like a C name-hiding bug from nested scopes.

Hmm.. could be related to one of the earlier bugs. clearly there is
something going wrong in one of the grin transformations.

> Minor issue, ForeignPtr  is missing a Show instance.                           
> Test.hs: http://www.mediafire.com/?e93sbeaoib26539
> test_code.c: http://www.mediafire.com/?16mj8agucypvp1x

Thanks for the report! 


John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/

More information about the jhc mailing list