Help debugging code broken after upgrading debian to GHC 6.12: "invalid argument"

I developed my Befunge interpreter that I posted here: http://coder.bsimmons.name/blog/2010/01/a-befunge-93-interpreter/ ...under GHC 6.8 Debian packages, and after revisiting the code, my interpreter fails on a particular file in a way that is truly baffling me. I don't even know where to begin. I am certain this code was working before, because the Befunge source it fails on is in my darcs test suite: The error I get is an InvalidArgument IOError. I'm not even sure what that means. Here are the imports I'm using in the module in case that makes the problem with my upgrade obvious: import System.Environment import Data.Char import Control.Arrow (first,second,(&&&),(|||)) import Data.Array.Unboxed import Control.Monad.State.Strict import System.Random import System.IO import System.IO.Error If anyone wants to look at my code and help me with this, they can download the three attached files and run the following: $> runghc Befunge.hs aturley.bf $> runghc Befunge.hs --quiet aturley.bf ...which should both print a pretty picture. Now try the file giving me problems: $> runghc Befunge.hs --quiet mycology.b98 ... which should give correct output (a bunch of line of "GOOD: blah...."). And finally: $> runghc Befunge.hs mycology.b98 ...which will (for me) simply print: "error processing options: invalid argument" The problem seems to have to do with line 427 and the call to `buildGrid` and the Bool value `wasBig`: while debugging I can print the array returned on that line, but trying to print the Bool simply fails with the error. The other baffling thing is this: if the debugging line 426 is uncommented, then even running: $> runghc Befunge.hs --quiet mycology.b98 ...will fail. But all we're doing is a call to `putStr`! Why would that trigger an error?! Maybe there was a bug in my code that was there before, but wasn't showing its head because something was being lazier than it is now? If anyone wants to take the time to help me with this, I would be most grateful. SIncerely, Brandon Simmons http://coder.bsimmons.name/

On May 14, 2010, at 20:24 , Brandon Simmons wrote:
The other baffling thing is this: if the debugging line 426 is uncommented, then even running:
$> runghc Befunge.hs --quiet mycology.b98
...will fail. But all we're doing is a call to `putStr`! Why would that trigger an error?! Maybe there was a bug in my code that was
GHC 6.12's runtime handles input and output encoding, instead of simply truncating Chars; my guess is it's locale-related. And sure enough, I see several non-ASCII characters in mycology.b98 which are likely to do the wrong thing if the runtime doesn't know which character set to use. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Saturday 15 May 2010 02:53:43, Brandon S. Allbery KF8NH wrote:
On May 14, 2010, at 20:24 , Brandon Simmons wrote:
The other baffling thing is this: if the debugging line 426 is uncommented, then even running:
$> runghc Befunge.hs --quiet mycology.b98
...will fail. But all we're doing is a call to `putStr`! Why would that trigger an error?! Maybe there was a bug in my code that was
GHC 6.12's runtime handles input and output encoding, instead of simply truncating Chars; my guess is it's locale-related. And sure enough, I see several non-ASCII characters in mycology.b98 which are likely to do the wrong thing if the runtime doesn't know which character set to use.
Yup. Converting mycology.b98 to utf-8 makes it run. However, why does it run with --quiet on the original file??
participants (3)
-
Brandon S. Allbery KF8NH
-
Brandon Simmons
-
Daniel Fischer