[Haskell-cafe] Crash!

Ross Mellgren rmm-haskell at z.odi.ac
Thu Oct 23 15:57:02 EDT 2008


In my experience it's pretty common for crashes to occur well after the 
original violation, if you stray off the path far enough into the stack 
or other fixed data structures.

Have you tried reformulating without using unsafeWrite, but using the 
safe writeArray alternative, to ensure that it's not an accidental stack 
smash or other uncouth behavior?

-Ross

Andrew Coppin wrote:
> Thomas DuBuisson wrote:
>>
>>         The point is... I'm not doing that. Gtk2hs is, but that's a
>>         well-tested library, so I very much doubt it's the source of
>>         the bug.
>>
>>
>>     so how would a bug in GTK or in libpng demonstrate itself ? i'm
>>     wondering, wouldn't it be a segfault ?
>>     does just wrapping them in some fancy haskell typed functions turn
>>     every library into a safe, typed haskell code ?
>>
>>
>> Sure it would, but the type system helps prevent programmers from 
>> misusing the (hopefully correctly implemented) functions and thus 
>> triggering an error due to bad input (ex: a pointer freed memory).  
>> And as Andrew said, GTK and its bindings are well tested so he is 
>> doubting that as the cause.  I wouldn't rule it out so fast, but GHC 
>> has compiled pure code and crashed for me before, so its shouldn't be 
>> surprising either way.
>
> This is the first time I've ever seen a Haskell program crash. (Unless 
> you purposely do something Very Bad to it - e.g., it crashes pretty 
> good if you try to run it without the GTK+ DLLs available, or run it 
> on an ancient version of Windows or something.)
>
>> As for fixing this problem, is there a bit more detailed error you 
>> could provide, Andrew?
>
> The problem arives inside a large, complicated program. The program 
> draws some stuff into an IOUArray, runs a convolution over it, and 
> then uses the GDK to write into a Pixbuf, which it then saves to a PNG 
> file. The IOUArray stuff is done using unsafeWrite, but that's the 
> only "unsafe" function used in the program. Usually the program works 
> flawlessly. However, if you ask it to draw to a certain combination of 
> coordinates, the program crashes. It's output indicates that it's 
> drawn to the IOUArray, it's run the convolution, and it's trying to 
> save the PNG file... but then a message pops up saying "the generated 
> code caused an access violation" and the program stops. (And sure 
> enough, an incomplete PNG file exists in the filesystem - so it really 
> has crashed part-way through writing it.)
>
> Theoretically, feeding invalid coordinates to the program might make 
> it run off the end of the IOUArray (or maybe off the beginning of it), 
> but I don't see what that has to do with GTK+...
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list