Ticket #2332 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

Can't allocate 4 gigs of RAM

Reported by: mightybyte Owned by: simonmar
Priority: normal Milestone: 6.10.1
Component: Runtime System Version: 6.8.2
Keywords: memory allocation Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The program at  http://hpaste.org/8058 produces a segmentation fault on my machine. I have 8 gigs of RAM, running 64-bit Ubuntu with 64-bit ghc. See  http://hpaste.org/8057 for another version of the same problem when using larger sizes.

Change History

Changed 5 years ago by igloo

  • owner set to simonmar
  • difficulty set to Unknown
  • milestone set to 6.10.1

The programs are

import Data.Word 
import Data.Array.IO 
import Data.Array 
import Data.Int 
 
main = do 
    a <- newArray_ (0, 2^32-1) :: IO (IOUArray Int Word8) 
    print =<< a `readArray` (2^32-1) 
    return ()

and

module Main where                                                                          
                                                                                           
import Data.Array.IO                                                                       
import Data.Array.Storable                                                                 
import Data.Int                                                                            
import IO                                                                                  
                                                                                           
buildTable1 :: Int -> IO (IOUArray Int Int8)
buildTable1 size = newArray (0,size-1) 0
                                                                                           
buildTable2 :: Int -> IO (StorableArray Int Int8)
buildTable2 size = newArray (0,size-1) 0
                                                                                           
go arr = do str <- getLine                                                                 
            val <- readArray arr (read str)                                                
            print val                                                                      
            writeArray arr (read str) (val+1)                                              
            go arr                                                                         
                                                                                           
--size = 4294967296 -- 4 * 2^30 (too big)
--size = 4294907296 -- Main: internal error...
size = 4290967296 -- works

main = do                                                                                  
  hSetBuffering stdout NoBuffering                                                         
  print $ ("Building table...",size)                                                       
  arr <- buildTable2 size 
  putStrLn ""                                                                              
  putStrLn "Ready."                                                                        
  go arr                                                                                   

Giving it to you, Simon, as I think you have or will have a machine with enough RAM to try to reproduce it!

Changed 5 years ago by simonmar

  • status changed from new to closed
  • resolution set to fixed
  • component changed from Compiler to Runtime System

Fixed:

Tue Jul 29 16:04:59 BST 2008  Simon Marlow <marlowsd@gmail.com>
  * FIX #2332: avoid overflow on 64-bit machines in the memory allocator
Note: See TracTickets for help on using tickets.