[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: rts: Properly free the RTSSummaryStats structure

Marge Bot gitlab at gitlab.haskell.org
Fri May 3 19:19:52 UTC 2019



 Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
7216aa97 by Ömer Sinan Ağacan at 2019-05-03T19:19:45Z
rts: Properly free the RTSSummaryStats structure

`stat_exit` always allocates a `RTSSummaryStats` but only sometimes
frees it, which casues leaks. With this patch we unconditionally free
the structure, fixing the leak.

Fixes #16584

- - - - -
fe982720 by Ömer Sinan Ağacan at 2019-05-03T19:19:47Z
StgCmmMonad: remove emitProc_, don't export emitProc

- - - - -
0dfdf9bf by Ömer Sinan Ağacan at 2019-05-03T19:19:47Z
PrimOps.cmm: remove unused stuff

- - - - -


3 changed files:

- compiler/codeGen/StgCmmMonad.hs
- rts/PrimOps.cmm
- rts/Stats.c


Changes:

=====================================
compiler/codeGen/StgCmmMonad.hs
=====================================
@@ -16,7 +16,7 @@ module StgCmmMonad (
 
         emitLabel,
 
-        emit, emitDecl, emitProc,
+        emit, emitDecl,
         emitProcWithConvention, emitProcWithStackFrame,
         emitOutOfLine, emitAssign, emitStore,
         emitComment, emitTick, emitUnwind,
@@ -738,14 +738,14 @@ emitProcWithStackFrame
 
 emitProcWithStackFrame _conv mb_info lbl _stk_args [] blocks False
   = do  { dflags <- getDynFlags
-        ; emitProc_ mb_info lbl [] blocks (widthInBytes (wordWidth dflags)) False
+        ; emitProc mb_info lbl [] blocks (widthInBytes (wordWidth dflags)) False
         }
 emitProcWithStackFrame conv mb_info lbl stk_args args (graph, tscope) True
         -- do layout
   = do  { dflags <- getDynFlags
         ; let (offset, live, entry) = mkCallEntry dflags conv args stk_args
               graph' = entry MkGraph.<*> graph
-        ; emitProc_ mb_info lbl live (graph', tscope) offset True
+        ; emitProc mb_info lbl live (graph', tscope) offset True
         }
 emitProcWithStackFrame _ _ _ _ _ _ _ = panic "emitProcWithStackFrame"
 
@@ -757,16 +757,12 @@ emitProcWithConvention conv mb_info lbl args blocks
   = emitProcWithStackFrame conv mb_info lbl [] args blocks True
 
 emitProc :: Maybe CmmInfoTable -> CLabel -> [GlobalReg] -> CmmAGraphScoped
-         -> Int -> FCode ()
-emitProc  mb_info lbl live blocks offset
- = emitProc_ mb_info lbl live blocks offset True
-
-emitProc_ :: Maybe CmmInfoTable -> CLabel -> [GlobalReg] -> CmmAGraphScoped
-          -> Int -> Bool -> FCode ()
-emitProc_ mb_info lbl live blocks offset do_layout
+         -> Int -> Bool -> FCode ()
+emitProc mb_info lbl live blocks offset do_layout
   = do  { dflags <- getDynFlags
         ; l <- newBlockId
         ; let
+              blks :: CmmGraph
               blks = labelAGraph l blocks
 
               infos | Just info <- mb_info = mapSingleton (g_entry blks) info


=====================================
rts/PrimOps.cmm
=====================================
@@ -34,9 +34,6 @@ import CLOSURE base_GHCziIOziException_heapOverflow_closure;
 import EnterCriticalSection;
 import LeaveCriticalSection;
 import CLOSURE ghczmprim_GHCziTypes_False_closure;
-#if defined(USE_MINIINTERPRETER) || !defined(mingw32_HOST_OS)
-import CLOSURE sm_mutex;
-#endif
 #if defined(PROFILING)
 import CLOSURE CCS_MAIN;
 #endif
@@ -1104,10 +1101,9 @@ INFO_TABLE_RET(stg_atomically_frame, ATOMICALLY_FRAME,
     return (P_ result) // value returned to the frame
 {
     W_ valid;
-    gcptr trec, outer, q;
+    gcptr trec;
 
-    trec   = StgTSO_trec(CurrentTSO);
-    outer  = StgTRecHeader_enclosing_trec(trec);
+    trec = StgTSO_trec(CurrentTSO);
 
     /* Back at the atomically frame */
     frame_result = result;


=====================================
rts/Stats.c
=====================================
@@ -657,11 +657,8 @@ static void init_RTSSummaryStats(RTSSummaryStats* sum)
 
 static void free_RTSSummaryStats(RTSSummaryStats * sum)
 {
-    if (!sum) { return; }
-    if (!sum->gc_summary_stats) {
-        stgFree(sum->gc_summary_stats);
-        sum->gc_summary_stats = NULL;
-    }
+    stgFree(sum->gc_summary_stats);
+    sum->gc_summary_stats = NULL;
 }
 
 static void report_summary(const RTSSummaryStats* sum)
@@ -1257,11 +1254,12 @@ stat_exit (void)
             }
         }
 
-        free_RTSSummaryStats(&sum);
         statsFlush();
         statsClose();
     }
 
+    free_RTSSummaryStats(&sum);
+
     if (GC_coll_cpu) {
       stgFree(GC_coll_cpu);
       GC_coll_cpu = NULL;



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/dc88a33dd84b6fd779c6cca327dbec61f26c55a0...0dfdf9bfd9cd2fc3bfc00151c0afcac7b31165ef

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/dc88a33dd84b6fd779c6cca327dbec61f26c55a0...0dfdf9bfd9cd2fc3bfc00151c0afcac7b31165ef
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190503/8ac480ac/attachment-0001.html>


More information about the ghc-commits mailing list