On a PPC Mac OS X 10.4, the RTS reports "Memory leak detected" running a program compiled with -debug -threaded -fhpc
On a PPC Mac OS X 10.4, the RTS reports "Memory leak detected" running a program compiled with -debug, -threaded, and -fhpc. Here is a sample session:
$ cat T1.hs
main = putStrLn "Memory leak?"
$ rm T1.o
$ /Users/thorkilnaur/tn/GHCDarcsRepository/ghc-HEAD-complete-for-pulling-and-copying-20070713_1212/ghc/compiler/stage2/ghc-inplace T1.hs -o T1 -debug -threaded -fhpc
$ ./T1
Memory leak detected
gen 0 blocks : 2
gen 1 blocks : 1
nursery : 128
retainer : 0
arena blocks : 0
exec : 0
free : 119
total : 250
in system : 254
T1: internal error: ASSERTION FAILED: file sm/Storage.c, line 1179
(GHC version 6.9.20080203 for powerpc_apple_darwin)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
$ ./T1
Memory leak?
$
Running the program usually fails the first time and succeeds on the second and subsequent attempts. The GHC version used is the HEAD from around 2008-Feb-03.
Similar behaviour has been observed for the test cases
ffi002(threaded1)
hpc001(threaded1)
hpc_fork(threaded1)
tough(threaded1)
for both the stable and head tnaur PPC OSX builders. The last three are all hpc test cases that use the same set of flags (-debug -threaded -fhpc) used in the above sample. ffi002 is different, it is an example of a C program that sets up the GHC runtime environment and calls some Haskell code. The ffi002 test case has been failing for a while (c.f. http://haskell.org/pipermail/cvs-ghc/2007-June/036013.html).
The memory leak is detected by this code in rts/sm/Storage.c
:
if (live_blocks + free_blocks != mblocks_allocated * BLOCKS_PER_MBLOCK)
{
debugBelch("Memory leak detected\n");
for (g = 0; g < RtsFlags.GcFlags.generations; g++) {
debugBelch(" gen %d blocks : %4lu\n", g, gen_blocks[g]);
}
debugBelch(" nursery : %4lu\n", nursery_blocks);
debugBelch(" retainer : %4lu\n", retainer_blocks);
debugBelch(" arena blocks : %4lu\n", arena_blocks);
debugBelch(" exec : %4lu\n", exec_blocks);
debugBelch(" free : %4lu\n", free_blocks);
debugBelch(" total : %4lu\n\n", live_blocks + free_blocks);
debugBelch(" in system : %4lu\n", mblocks_allocated * BLOCKS_PER_MBLOCK);
ASSERT(0);
}
I have tried to move the printing of counters outside the condition and got the following result:
$ rm T1.o
$ /Users/thorkilnaur/tn/GHCDarcsRepository/ghc-HEAD-complete-for-pulling-and-copying-20070713_1212/ghc/compiler/stage2/ghc-inplace T1.hs -o T1 -debug -threaded -fhpc
$ ./T1
memInventory:
gen 0 blocks : 2
gen 1 blocks : 1
nursery : 128
retainer : 0
arena blocks : 0
exec : 0
free : 119
total : 250
in system : 254
Memory leak detected
T1: internal error: ASSERTION FAILED: file sm/Storage.c, line 1181
(GHC version 6.9.20080203 for powerpc_apple_darwin)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
$ ./T1
Memory leak?
memInventory:
gen 0 blocks : 2
gen 1 blocks : 1
nursery : 128
retainer : 0
arena blocks : 0
exec : 0
free : 123
total : 254
in system : 254
memInventory:
gen 0 blocks : 4
gen 1 blocks : 4
nursery : 128
retainer : 0
arena blocks : 0
exec : 0
free : 118
total : 254
in system : 254
$
Suggestions for further lines of investigation are most welcome.
Best regards Thorkil
Trac metadata
Trac field | Value |
---|---|
Version | 6.9 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Runtime System |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |