Ticket #5541 (closed bug: invalid)

Opened 20 months ago

Last modified 19 months ago

Data.Bits.setBit misbehaves on bad input

Reported by: nomeata Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.0.4
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime crash Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

While

ghc -e 'Data.Bits.setBit 0 (2^36::Int) :: Integer'

seems to “work” (allocates lots of memory and keeps calculating), it mis-behaves with larger numbers:

$ ghc -e 'Data.Bits.setBit 0 (2^37::Int) :: Integer'
gmp: overflow in mpz type
Abgebrochen

If gmp cannot cope with that number, an exception should be raised, but not the whole process terminated.

Natuarlly, this is not a very critical bug.

Change History

Changed 20 months ago by daniel.is.fischer

gmp itself calls abort() when trying to allocate too much. Is it sensible to install a handler for SIGABRT to transform it into a Haskell exception?

Changed 19 months ago by igloo

  • status changed from new to closed
  • resolution set to invalid

We've just been discussing this on IRC, and the conclusion is that we can't stop abort from terminating the process; from the abort manpage:

       If  the SIGABRT signal is ignored, or caught by a handler that returns,
       the abort() function will still terminate the process.  It does this by
       restoring the default disposition for SIGABRT and then raising the sig‐
       nal for a second time.
Note: See TracTickets for help on using tickets.