[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Fix #16525: ObjectCode freed wrongly because of lack of info header check

Marge Bot gitlab at gitlab.haskell.org
Tue Jun 11 05:09:07 UTC 2019



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


Commits:
0a68dfeb by Phuong Trinh at 2019-06-11T05:09:02Z
Fix #16525: ObjectCode freed wrongly because of lack of info header check

`checkUnload` currently doesn't check the info header of static objects.
Thus, it may free an `ObjectCode` struct wrongly even if there's still a
live static object whose info header lies in a mapped section of that
`ObjectCode`. This fixes the issue by adding an appropriate check.

- - - - -
20203f19 by Alp Mestanogullari at 2019-06-11T05:09:04Z
testsuite/mk/boilerplate.mk: rename 'ghc-config-mk' to 'ghc_config_mk'

Make/shell variable names which contain dashes can cause problems under
some conditions. The 'ghc-config-mk' variable from testsuite/mk/boilerplate.mk
that I made overridable (by Hadrian) in ba0aed2e was working as expected when
our Hadrian/Linux job was based off the deb8 Docker image, but broke when
I switched the job to use our deb9-based image, in 3d97bad6. The exact
circumstances/tool versions that trigger this problem are unknown, but
changing the variable's name to 'ghc_config_mk' lets us work around the issue.

This fixes the annth_compunits and annth_make test failures that showed up
when we switched the Hadrian/Linux job to use the deb9 environment.

- - - - -


10 changed files:

- hadrian/src/Rules/Test.hs
- rts/CheckUnload.c
- rts/Linker.c
- rts/linker/M32Alloc.c
- testsuite/mk/boilerplate.mk
- + testsuite/tests/ghci/T16525a/A.hs
- + testsuite/tests/ghci/T16525a/B.hs
- + testsuite/tests/ghci/T16525a/T16525a.script
- + testsuite/tests/ghci/T16525a/T16525a.stdout
- + testsuite/tests/ghci/T16525a/all.T


Changes:

=====================================
hadrian/src/Rules/Test.hs
=====================================
@@ -122,7 +122,7 @@ testRules = do
             -- This lets us bypass the need to generate a config
             -- through Make, which happens in testsuite/mk/boilerplate.mk
             -- which is in turn included by all test 'Makefile's.
-            setEnv "ghc-config-mk" (top -/- root -/- ghcConfigPath)
+            setEnv "ghc_config_mk" (top -/- root -/- ghcConfigPath)
 
         -- Execute the test target.
         -- We override the verbosity setting to make sure the user can see


=====================================
rts/CheckUnload.c
=====================================
@@ -404,6 +404,7 @@ void checkUnload (StgClosure *static_objects)
       p = UNTAG_STATIC_LIST_PTR(p);
       checkAddress(addrs, p, s_indices);
       info = get_itbl(p);
+      checkAddress(addrs, info);
       link = *STATIC_LINK(info, p);
   }
 


=====================================
rts/Linker.c
=====================================
@@ -1176,11 +1176,17 @@ void freeObjectCode (ObjectCode *oc)
                            oc->sections[i].mapped_size);
                     break;
                 case SECTION_M32:
+                    IF_DEBUG(sanity,
+                        memset(oc->sections[i].start,
+                            0x00, oc->sections[i].size));
                     m32_free(oc->sections[i].start,
                              oc->sections[i].size);
                     break;
 #endif
                 case SECTION_MALLOC:
+                    IF_DEBUG(sanity,
+                        memset(oc->sections[i].start,
+                            0x00, oc->sections[i].size));
                     stgFree(oc->sections[i].start);
                     break;
                 default:


=====================================
rts/linker/M32Alloc.c
=====================================
@@ -24,7 +24,7 @@ Note [Compile Time Trickery]
 This file implements two versions of each of the `m32_*` functions. At the top
 of the file there is the real implementation (compiled in when
 `RTS_LINKER_USE_MMAP` is true) and a dummy implementation that exists only to
-satisfy the compiler and which hould never be called. If any of these dummy
+satisfy the compiler and which should never be called. If any of these dummy
 implementations are called the program will abort.
 
 The rationale for this is to allow the calling code to be written without using


=====================================
testsuite/mk/boilerplate.mk
=====================================
@@ -240,17 +240,17 @@ $(TOP)/mk/ghc-config : $(TOP)/mk/ghc-config.hs
 
 empty=
 space=$(empty) $(empty)
-ifeq "$(ghc-config-mk)" ""
-ghc-config-mk = $(TOP)/mk/ghcconfig$(subst $(space),_,$(subst :,_,$(subst /,_,$(subst \,_,$(TEST_HC))))).mk
+ifeq "$(ghc_config_mk)" ""
+ghc_config_mk = $(TOP)/mk/ghcconfig$(subst $(space),_,$(subst :,_,$(subst /,_,$(subst \,_,$(TEST_HC))))).mk
 
-$(ghc-config-mk) : $(TOP)/mk/ghc-config
+$(ghc_config_mk) : $(TOP)/mk/ghc-config
 	$(TOP)/mk/ghc-config "$(TEST_HC)" >"$@"; if [ $$? != 0 ]; then $(RM) "$@"; exit 1; fi
 # If the ghc-config fails, remove $@, and fail
 endif
 
 # Note: $(CLEANING) is not defined in the testsuite.
 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
--include $(ghc-config-mk)
+-include $(ghc_config_mk)
 endif
 
 # Note [WayFlags]


=====================================
testsuite/tests/ghci/T16525a/A.hs
=====================================
@@ -0,0 +1,12 @@
+module A where
+
+import B
+
+myIntVal :: Int
+myIntVal = sum [1,2,3,4]
+
+value :: [Value]
+value = [Value "a;lskdfa;lszkfsd;alkfjas" myIntVal]
+
+v1 :: Value -> String
+v1 (Value a _) = a


=====================================
testsuite/tests/ghci/T16525a/B.hs
=====================================
@@ -0,0 +1,3 @@
+module B where
+
+data Value = Value String Int


=====================================
testsuite/tests/ghci/T16525a/T16525a.script
=====================================
@@ -0,0 +1,6 @@
+:set -fobject-code
+:load A
+import Control.Concurrent
+_ <- forkIO $ threadDelay 1000000 >> (print (map v1 value))
+:l []
+System.Mem.performGC


=====================================
testsuite/tests/ghci/T16525a/T16525a.stdout
=====================================


=====================================
testsuite/tests/ghci/T16525a/all.T
=====================================
@@ -0,0 +1,5 @@
+test('T16525a',
+     [extra_files(['A.hs', 'B.hs', ]),
+      extra_run_opts('+RTS -DS -RTS'),
+      when(ghc_dynamic(), skip), ],
+     ghci_script, ['T16525a.script'])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/1d3c656ef5d3635bac84522e41d4ff59918e3632...20203f193dc5e3f81ddeb9ec64ed5787b58e94fc

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/1d3c656ef5d3635bac84522e41d4ff59918e3632...20203f193dc5e3f81ddeb9ec64ed5787b58e94fc
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/20190611/09022802/attachment-0001.html>


More information about the ghc-commits mailing list