[Hugs-bugs] coredump on innocent code

Ross Paterson ross at soi.city.ac.uk
Thu Sep 8 12:53:25 EDT 2005


On Thu, Sep 08, 2005 at 04:00:47PM +0000, fool at sdf-eu.org wrote:
> $ cat bug.hs
> main = print (let (x,(q,_)) = (1,divMod x x) in q)
> $ runhugs bug.hs
> Illegal instruction (core dumped)

Not entirely innocent: demand for x also causes evaluation of the second
pair, which depends on x: an infinite loop.  The correct version is

	main = print (let (x,~(q,_)) = (1,divMod x x) in q)

Unfortunately, it's a known bug that some infinite loops cause Hugs to
overrun the C stack, crashing the program.  (This is caught under Windows,
but not Unix.)



More information about the Hugs-Bugs mailing list