Ticket #3514 (closed merge: fixed)
mallocPlainForeignPtrBytes -1000 gives runtime internal error: allocGroup: requested zero blocks
|Reported by:||andrewbirkett||Owned by:||igloo|
|Type of failure:||None/Unknown||Difficulty:||Unknown|
|Test Case:||Blocked By:|
Passing negative numbers to mallocPlainForeignPtrBytes causes the following to appear:
Test: internal error: allocGroup: requested zero blocks (GHC version 6.10.4 for i386_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Aborted
Originally, a bug in my app meant that I called Data.ByteString?.hGet with a negative 'numBytes' argument, however I've managed to boil it down to a one line test case involving just mallocPlainForeignPtrBytes as follows:
$ cat Test.hs import GHC.ForeignPtr (mallocPlainForeignPtrBytes) main = mallocPlainForeignPtrBytes (-1000) $ ghc --make Test.hs [1 of 1] Compiling Main ( Test.hs, Test.o ) Linking Test ... $ ./Test Test: internal error: allocGroup: requested zero blocks (GHC version 6.10.4 for i386_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Aborted
The magnitude of the number appears to have some effect; with ghc 6.10.1 it seemed to reliably crash with numBytes <= -9. But when I upgraded to ghc 6.10.4, the test case started working. However, changing to -1000 reliably causes a crash on my box - perhaps the behaviour depends on heap layout. Either way, the function should probably behave more gracefully .. perhaps raising an exception.
Full gory details of my setup (ie. ghc -v output, gcc version) are attached because they messed up the formatting.