#2087: On a PPC Mac OS X 10.4, the RTS reports "Memory leak detected" running a
program compiled with -debug -threaded -fhpc
----------------------------+-----------------------------------------------
 Reporter:  thorkilnaur     |          Owner:         
     Type:  bug             |         Status:  new    
 Priority:  normal          |      Milestone:  6.8.3  
Component:  Runtime System  |        Version:  6.9    
 Severity:  normal          |     Resolution:         
 Keywords:                  |     Difficulty:  Unknown
 Testcase:                  |   Architecture:  powerpc
       Os:  MacOS X         |  
----------------------------+-----------------------------------------------
Comment (by thorkilnaur):

 Additional investigation strongly indicates that the uncounted blocks are
 the ones allocated by {{{hs_add_root}}} in {{{RtsStartup.c}}}:
 {{{
 void
 hs_add_root(void (*init_root)(void))
 {
     bdescr *bd;
     nat init_sp;
     Capability *cap = &MainCapability;

     if (hs_init_count <= 0) {
         barf("hs_add_root() must be called after hs_init()");
     }

     /* The initialisation stack grows downward, with sp pointing
        to the last occupied word */
     init_sp = INIT_STACK_BLOCKS*BLOCK_SIZE_W;
     bd = allocGroup_lock(INIT_STACK_BLOCKS);
     init_stack = (F_ *)bd->start;
     init_stack[--init_sp] = (F_)stg_init_finish;
     if (init_root != NULL) {
         init_stack[--init_sp] = (F_)init_root;
     }

     cap->r.rSp = (P_)(init_stack + init_sp);
     StgRun((StgFunPtr)stg_init, &cap->r);

     freeGroup_lock(bd);

     startupHpc();

     // This must be done after module initialisation.
     // ToDo: make this work in the presence of multiple hs_add_root()s.
     initProfiling2();
 }
 }}}
 The memory leak is reported when a garbage collection happens to be
 initiated before the blocks are freed again. This can be confirmed by
 inserting a call to memInventory between the allocation and the free: Such
 a call reports the memory leak every time.

 So it is not actually a real memory leak, merely a weakness in the memory
 leak detector.

 I will gladly concoct a repair of this problem, but the possibilities are
 many, so I will just hesitate for a little while and see if not somebody
 else might come up with just the right solution.

 Thanks and best regards Thorkil

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2087#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to