This is so enraging! > _ <
I wrote a huge, complex Haskell library. I wrote a small trial program, and so far I have spent about 8 hours trying to figure out why the hell is it crashing down on me. Sometimes the GHC complains about the "weird closure type." Sometimes I just get segfault. Obviously, the problem is memory corruption.
The library itself is 100% pure Haskell. However, the test program uses several unsafe GHC primitives related to arrays. This is obviously what causes the problem. Indeed, if I comment out the line writeArray#, the program will stop crashing. But it completely fries my noodles ... as far as I can tell, all the boundaries of the array that I used are perfectly correct. The program prints them all, and all of them are positive and smaller than the size of the array.
I wrote a second program that does the same thing as the first, but without involving a huge complex library. I tried, tried and tried, but I can't make it crash. Nothing I do seems to cause it to crash, and yet it almost exactly matches the actual arrays.
Does anyone have additional troubleshooting tips? Is there a way to track the exact moment when the memory gets corrupted? (Instead of the moment the system notices damage.)
Update:
What makes the problem?
Well, essentially, it creates an array representing a pixel buffer. It generates one stream that iterates over each pixel and writes the corresponding value to it. And it generates a second stream that reads the array, and writes the pixels to the network socket using a rather complicated protocol. (Means, a large library that I am trying to check.)
, . writeArray' , . . , , A-OK. ... .
, GHC -. ( , - , , , , .)
, , . . , . ?!
: http://hpaste.org/70987
: http://hpaste.org/70988