Haskwhal

Missteps of a Narwhal Calf

Previous Entry Add to Memories Share Next Entry
Segmentation Fault and small files for errors
king, avatar, owl, ozten, austin
ozten
I don't know if I should be proud of myself or not... but my toy application has Seg Faulted ghc :/

I found to suspicious things
  • Calling commit on a connection that had already been disconnected

  • Trying read an int out of the textual representation of a
    Data.ByteString.Lazy.Char8
    and insert it into the database


I'm not quite sure, but fixing those two things have fixed the issue.

Another thing I'm noticing is to keep files extremely small, because while compile errors are verbose, runtime error reporting in ghci is very weak. Seg Fault gave me nothing... The error
Prelude.read: no parse

Gives me just a filename and no line number.

I'm excited I've reached a milestone in my toy application... I can

  • Send out HTML

  • Include data from the Database in the HTML

  • Process input from a form

  • Save the data to the db

  • Do a redirect


It's taken quite a few hours in 30 minute chunks to get this far. It's a good problem for exercising basic Haskell knowledge.

Those Prelude.read errors happen when a call to "read" can't find a parser for the data type it is being called on. For example, I once tried to cast strings (well, UUIDs to strings to ints) to ints by reading the string as ASCII. But it didn't work. The default "read" implementation only handles characters that are numbers. Replacing by "sum $ map ord $ string" worked okay (but there are overflow issues to deal with then)
(Frozen) (Thread)

You are viewing ozten