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

Marge Bot gitlab at gitlab.haskell.org
Tue Jun 11 10:39:32 UTC 2019



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


Commits:
6c7d73c8 by Phuong Trinh at 2019-06-11T10:39:17Z
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.

- - - - -
d277632e by Alec Theriault at 2019-06-11T10:39:19Z
Make `haddock_testsuite` respect `--test-accept`

Suppose you've made changes that affect the output of `haddockHtmlTest`
so that the following is failing:

    ./hadrian/build.sh -c --only=haddockHtmlTest test

Then, the following will accept new output for Haddock's test cases.

    ./hadrian/build.sh -c --only=haddockHtmlTest test --test-accept

You still do need to make sure those new changes (which show up in
Haddock's tree) get committed though.

Fixes #16694

- - - - -
637c5388 by Alp Mestanogullari at 2019-06-11T10:39:20Z
rts/RtsFlags.c: mention that -prof too enables support for +RTS -l

- - - - -
7baef20f by Alp Mestanogullari at 2019-06-11T10:39:21Z
Hadrian: teach the RTS that PROFILING implies TRACING

As discussed in #16744, both the Make and Hadrian build systems
have special code to always pass -eventlog whenever -prof or -debug
are passed. However, there is some similar logic in the RTS itself only
for defining TRACING when the DEBUG macro is defined, but no such logic
is implemented to define TRACING when the PROFILING macro is defined.
This patch adds such a logic and therefore fixes #16744.

- - - - -
27d31a3b by Ömer Sinan Ağacan at 2019-06-11T10:39:26Z
Fix an error message in CheckUnload.c:searchHeapBlocks

- - - - -
13d8adec by Alp Mestanogullari at 2019-06-11T10:39:27Z
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.

- - - - -


15 changed files:

- docs/users_guide/phases.rst
- hadrian/src/Rules/Test.hs
- includes/rts/Config.h
- rts/CheckUnload.c
- rts/Linker.c
- rts/RtsFlags.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
- testsuite/tests/haddock/haddock_testsuite/Makefile
- testsuite/tests/haddock/haddock_testsuite/all.T


Changes:

=====================================
docs/users_guide/phases.rst
=====================================
@@ -365,7 +365,7 @@ defined by your local GHC installation, the following trick is useful:
 
     .. code-block:: c
 
-        #ifdef MIN_VERSION_GLASGOW_HASKELL
+        #if defined(MIN_VERSION_GLASGOW_HASKELL)
         #if MIN_VERSION_GLASGOW_HASKELL(7,10,2,0)
         /* code that applies only to GHC 7.10.2 or later */
         #endif


=====================================
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


=====================================
includes/rts/Config.h
=====================================
@@ -26,11 +26,15 @@
 #define USING_LIBBFD 1
 #endif
 
-/* DEBUG implies TRACING and TICKY_TICKY  */
-#if defined(DEBUG)
+/* DEBUG and PROFILING both imply TRACING */
+#if defined(DEBUG) || defined(PROFILING)
 #if !defined(TRACING)
 #define TRACING
 #endif
+#endif
+
+/* DEBUG implies TICKY_TICKY */
+#if defined(DEBUG)
 #if !defined(TICKY_TICKY)
 #define TICKY_TICKY
 #endif


=====================================
rts/CheckUnload.c
=====================================
@@ -335,7 +335,7 @@ static void searchHeapBlocks (HashTable *addrs, bdescr *bd,
                 break;
 
             default:
-                barf("heapCensus, unknown object: %d", info->type);
+                barf("searchHeapBlocks, unknown object: %d", info->type);
             }
 
             if (!prim) {
@@ -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/RtsFlags.c
=====================================
@@ -830,7 +830,7 @@ error = true;
 # define TRACING_BUILD_ONLY(x)   x
 #else
 # define TRACING_BUILD_ONLY(x) \
-errorBelch("the flag %s requires the program to be built with -eventlog or -debug", \
+errorBelch("the flag %s requires the program to be built with -eventlog, -prof or -debug", \
            rts_argv[arg]);                                              \
 error = true;
 #endif


=====================================
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'])


=====================================
testsuite/tests/haddock/haddock_testsuite/Makefile
=====================================
@@ -24,6 +24,7 @@ htmlTest:
 		$(haddockTest) \
 		$(TOP)/../utils/haddock/html-test/Main.hs
 	./html-test \
+		$(ACCEPT) \
 		--ghc-path=$(TEST_HC) \
 		--haddock-path=$(HADDOCK) \
 		--haddock-stdout=haddock-out.log
@@ -39,6 +40,7 @@ latexTest:
 		$(haddockTest) \
 		$(TOP)/../utils/haddock/latex-test/Main.hs
 	./latex-test \
+		$(ACCEPT) \
 		--ghc-path=$(TEST_HC) \
 		--haddock-path=$(HADDOCK) \
 		--haddock-stdout=haddock-out.log
@@ -54,6 +56,7 @@ hoogleTest:
 		$(haddockTest) \
 		$(TOP)/../utils/haddock/hoogle-test/Main.hs
 	./hoogle-test \
+		$(ACCEPT) \
 		--ghc-path=$(TEST_HC) \
 		--haddock-path=$(HADDOCK) \
 		--haddock-stdout=haddock-out.log
@@ -69,6 +72,7 @@ hypsrcTest:
 		$(haddockTest) \
 		$(TOP)/../utils/haddock/hypsrc-test/Main.hs
 	./hypsrc-test \
+		$(ACCEPT) \
 		--ghc-path=$(TEST_HC) \
 		--haddock-path=$(HADDOCK) \
 		--haddock-stdout=haddock-out.log


=====================================
testsuite/tests/haddock/haddock_testsuite/all.T
=====================================
@@ -1,19 +1,21 @@
+accept = 'ACCEPT=--accept' if config.accept else 'ACCEPT=""'
+
 test('haddockHtmlTest',
      [ignore_stdout, ignore_stderr, unless(in_tree_compiler(), skip), req_haddock],
      makefile_test,
-     ['htmlTest'])
+     ['htmlTest ' + accept])
 
 test('haddockLatexTest',
      [ignore_stdout, ignore_stderr, unless(in_tree_compiler(), skip), req_haddock],
      makefile_test,
-     ['latexTest'])
+     ['latexTest ' + accept])
 
 test('haddockHoogleTest',
      [ignore_stdout, ignore_stderr, unless(in_tree_compiler(), skip), req_haddock],
      makefile_test,
-     ['hoogleTest'])
+     ['hoogleTest ' + accept])
 
 test('haddockHypsrcTest',
      [ignore_stdout, ignore_stderr, unless(in_tree_compiler(), skip), req_haddock],
      makefile_test,
-     ['hypsrcTest'])
+     ['hypsrcTest ' + accept])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/20203f193dc5e3f81ddeb9ec64ed5787b58e94fc...13d8adec0022b018696a26b65df775a99e641701

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/20203f193dc5e3f81ddeb9ec64ed5787b58e94fc...13d8adec0022b018696a26b65df775a99e641701
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/a38039c8/attachment-0001.html>


More information about the ghc-commits mailing list