I'm using the Feb 2000 release of Hugs and am preparing student labs using the graphics library. Several nasties happen: * For very moderate problems (plot ~2K lines centred in a window of fixed size) I get a control stack overflow. To centre, the code finds pre-computes the minimum and maximum x and y ordinates of all line end-points. This is potentially a problem, but fixable in this case, you'd hope. However, the overflow happens EVEN IF the code is written tail-recursive, or using foldl. Oh dear. * If the relevant scaling factors are passed as parameters (to avoid pre-computation) I can plot quite a bit more (4997 lines on my W2000 set-up; rather more on an earlier installation under W98). But then the program aborts, presumably because of the C stack overflow problem. * On W2000 the previous problem corrupts the WHOLE screen buffer, rather like a virus. Actually this is fixable by maximising and then minimising the hugs window, but it's all very disturbing! On W98, the programs seems to die gracefully. So question: how do I increase the stack size? Also, are you aware of problems with the graphics library burning up the C stack? I cannot find anything in the hugs documentation, but have a feeling you have to recompile Hugs. Is this true? (Otherwise Hugs is completely wonderful...!) Many thanks. Tony Field Imperial College
Hi,
any chance of having a look at the code that's causing these
problems?
The only way to increase the Hugs control stack size is by
recompiling the sources, after having tweaked NUM_STACK
in prelude.h
The default C stack size on Win32 is 1MB, and you can change this
by re-linking with "/link /stack:<reserve>" added to the link line (this
is with MSVC tools & <reserve> being the size in bytes).
hth
--sigbjorn
----- Original Message -----
From: "ajf"
I'm using the Feb 2000 release of Hugs and am preparing student labs using the graphics library. Several nasties happen:
* For very moderate problems (plot ~2K lines centred in a window of fixed size) I get a control stack overflow. To centre, the code finds pre-computes the minimum and maximum x and y ordinates of all line end-points. This is potentially a problem, but fixable in this case, you'd hope. However, the overflow happens EVEN IF the code is written tail-recursive, or using foldl. Oh dear.
* If the relevant scaling factors are passed as parameters (to avoid pre-computation) I can plot quite a bit more (4997 lines on my W2000 set-up; rather more on an earlier installation under W98). But then the program aborts, presumably because of the C stack overflow problem.
* On W2000 the previous problem corrupts the WHOLE screen buffer, rather like a virus. Actually this is fixable by maximising and then minimising the hugs window, but it's all very disturbing! On W98, the programs seems to die gracefully.
So question: how do I increase the stack size? Also, are you aware of problems with the graphics library burning up the C stack? I cannot find anything in the hugs documentation, but have a feeling you have to recompile Hugs. Is this true?
(Otherwise Hugs is completely wonderful...!)
Many thanks.
Tony Field Imperial College
_______________________________________________ Hugs-Bugs mailing list Hugs-Bugs@haskell.org http://www.haskell.org/mailman/listinfo/hugs-bugs
I'm using the Feb 2000 release of Hugs and am preparing student labs using the graphics library. Several nasties happen:
* For very moderate problems (plot ~2K lines centred in a window of fixed size) I get a control stack overflow. To centre, the code finds pre-computes the minimum and maximum x and y ordinates of all line end-points. This is potentially a problem, but fixable in this case, you'd hope. However, the overflow happens EVEN IF the code is written tail-recursive, or using foldl. Oh dear.
This could well be a strictness problem. foldl often has little effect on strictness problems. What you need is foldl' which forces (using $!) the accumulator parameter on each iteration. foldl' is defined and used in Hugs' Prelude but is not exported because it is not sanctioned by the Haskell standard. foldl' :: (a -> b -> a) -> a -> [b] -> a foldl' f a [] = a foldl' f a (x:xs) = (foldl' f $! f a x) xs As for why Hugs and the HGL are able to corrupt the entire screen on Win2000, I can only say that I am very impressed by MS's ability to put so much functionality into their system and have it ever work. :-) -- Alastair Reid reid@cs.utah.edu http://www.cs.utah.edu/~reid/
Alastair David Reid
....
As for why Hugs and the HGL are able to corrupt the entire screen on Win2000, I can only say that I am very impressed by MS's ability to put so much functionality into their system and have it ever work. :-)
Well, I'm not terribly impressed by the Graphics library 1/2 ;-) You absolutely have to release window DCs you grab via GetDC() to avoid running out of resources -- this is Petzold-101 stuff. So, to avoid seeing side-effects of running out of DCs, I suggest you change GraphicsWND.drawWND to: drawWND :: WND -> Draw () -> IO () drawWND wnd p = do hwnd <- getHWND wnd withDC (Just hwnd) (unDraw p) hth --sigbjorn
participants (3)
-
ajf -
Alastair David Reid -
Sigbjorn Finne