[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-jhc
Subject:    [jhc] =?windows-1256?q?bugs/issues_in_jhc-0=2E7=2E6=FE?=
From:       Korcan Hussein <korcan_h () hotmail ! com>
Date:       2010-08-07 11:27:10
Message-ID: SNT118-W19EE8A9D70DCC392FBC45BE2920 () phx ! gbl
[Download RAW message or body]


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.  
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)
test_code.c:4136: error: (Each undeclared identifier is reported only once
test_code.c:4136: error: for each function it appears in.)
 
This is generated for the code:
 
failWithError :: String -> IO a
failWithError msg
    = do err <- fmap (fromMaybe "No SDL error") getError
         ioError $ userError $ msg ++ "\nSDL message: " ++ err
 
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.
 
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"
 
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.  
Minor issue, ForeignPtr  is missing a Show instance.                           

Test.hs: http://www.mediafire.com/?e93sbeaoib26539
test_code.c: http://www.mediafire.com/?16mj8agucypvp1x

 		 	   		  
_______________________________________________
jhc mailing list
jhc@haskell.org
http://www.haskell.org/mailman/listinfo/jhc


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic