Eric Kow wrote:
> Hi Jules,
>
> Is this the same bug as this one from the Tracker?
>
> http://sourceforge.net/tracker/index.php?func=detail&aid=1003006&group_id=73133&atid=536845
>
> (was submitted by Paul Johnson, I think)
>
> Also, if you are so inclined, it would be extra-helpful if you could
> submit your demonstrator as a test case in the bugs/ directory (darcs
> send). It would be extra-extra-helpful if you could work out a way to
> reproduce this bug very consistently (for example, by repeatedly
> loading the image in or something)
Hi Eric,
It does look like it could well be the same bug. Although seems
surprising for there to be a hole in the memory? Perhaps it is being
moved by GC... but GC doesn't move memory which was allocated by a C(++)
library does it?
I can reproduce the bug simply by creating images over and over and over
again.
Here is a fairly minimal testcase, at the bottom of this mail. It always
seems to segfault for me, normally after about 5 iterations, sometimes
as many as 22.
It's interesting that there is a very long pause before the segfault.
That is, one iteration of creating an image is normally a tiny tiny
fraction of a second, but if it's going to segfault, there is a long pause.
I tried running with -Sstderr to see if I could see an obvious link
between garbage collections and crashes, but if there is one it isn't
obvious to me!
Happy to try more stuff to pin this down, let me know what I can do.
Jules
import qualified Graphics.UI.WX as WX
import Graphics.UI.WXCore.Image
import Graphics.UI.WXCore.Draw
import Graphics.UI.WXCore.WxcClassesAL
import Graphics.UI.WXCore.WxcClassesMZ
import Foreign
import Data.Word
import Control.Monad
main = do
forM_ [0..500]
(\i -> putStrLn ("Iteration : " ++ show i) >> createAndGetPixels)
createAndGetPixels = do
bmp <- bitmapCreateEmpty (WX.Size 256 256) 24
pixelsFromBitmap bmp
pixelsFromBitmap bmp = do
image <- imageCreateFromBitmap bmp
pixels <- imageGetData image
putStrLn $ "pixels : " ++ show pixels
bytes <- peekArray 8 (castPtr pixels)
putStrLn $ "bytes : " ++ show (bytes :: [Word8])
WX.Size w h <- imageGetSize image
putStrLn $ "Image size : " ++ show (w,h)
pixs <- imageGetPixels image
putStrLn $ "number of pixs = " ++ show (length pixs)
putStrLn $ "first pixel " ++ show (head pixs)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
wxhaskell-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users