#3514: mallocPlainForeignPtrBytes -1000 gives runtime internal error: 
allocGroup:
requested zero blocks
--------------------------+-------------------------------------------------
Reporter:  andrewbirkett  |          Owner:                
    Type:  bug            |         Status:  new           
Priority:  normal         |      Component:  Runtime System
 Version:  6.10.4         |       Severity:  minor         
Keywords:                 |       Testcase:                
      Os:  Linux          |   Architecture:  x86           
--------------------------+-------------------------------------------------
 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3514>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to