[commit: ghc] ghc-8.0: RtClosureInspect: Fix off-by-one error in cvReconstructType (54413fd)

git at git.haskell.org git at git.haskell.org
Tue Aug 30 21:43:42 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/54413fd1b004def92d629e85499caef53832d8ee/ghc

>---------------------------------------------------------------

commit 54413fd1b004def92d629e85499caef53832d8ee
Author: mniip <mniip at mniip.com>
Date:   Tue Aug 23 13:19:02 2016 -0400

    RtClosureInspect: Fix off-by-one error in cvReconstructType
    
    Replaced error-prone index manipulation on a pointer array with
    a simple fold on the array elements.
    
    Test Plan: Added a test case that triggers the bug
    
    Reviewers: hvr, austin, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: simonpj, thomie
    
    Differential Revision: https://phabricator.haskell.org/D2439
    
    GHC Trac Issues: #12458
    
    (cherry picked from commit 1766bb3cfd1460796c78bd5651f89d53603586f9)


>---------------------------------------------------------------

54413fd1b004def92d629e85499caef53832d8ee
 compiler/ghci/RtClosureInspect.hs                   | 7 +++----
 testsuite/tests/ghci.debugger/scripts/T12458.script | 4 ++++
 testsuite/tests/ghci.debugger/scripts/T12458.stdout | 2 ++
 testsuite/tests/ghci.debugger/scripts/all.T         | 1 +
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/compiler/ghci/RtClosureInspect.hs b/compiler/ghci/RtClosureInspect.hs
index 86e9a00..9ed6cfb 100644
--- a/compiler/ghci/RtClosureInspect.hs
+++ b/compiler/ghci/RtClosureInspect.hs
@@ -905,10 +905,9 @@ cvReconstructType hsc_env max_depth old_ty hval = runTR_maybe hsc_env $ do
         (_,mb_dc)    <- tryTcErrs (tcLookupDataCon dcname)
         case mb_dc of
           Nothing-> do
-                     --  TODO: Check this case
-            forM [0..length (elems $ ptrs clos)] $ \i -> do
-                        tv <- newVar liftedTypeKind
-                        return$ appArr (\e->(tv,e)) (ptrs clos) i
+            forM (elems $ ptrs clos) $ \a -> do
+              tv <- newVar liftedTypeKind
+              return (tv, a)
 
           Just dc -> do
             arg_tys <- getDataConArgTys dc my_ty
diff --git a/testsuite/tests/ghci.debugger/scripts/T12458.script b/testsuite/tests/ghci.debugger/scripts/T12458.script
new file mode 100644
index 0000000..5d4120d
--- /dev/null
+++ b/testsuite/tests/ghci.debugger/scripts/T12458.script
@@ -0,0 +1,4 @@
+data D a = D
+d = D
+:print d
+d `seq` ()
diff --git a/testsuite/tests/ghci.debugger/scripts/T12458.stdout b/testsuite/tests/ghci.debugger/scripts/T12458.stdout
new file mode 100644
index 0000000..2a616b0
--- /dev/null
+++ b/testsuite/tests/ghci.debugger/scripts/T12458.stdout
@@ -0,0 +1,2 @@
+d = (_t1::D a)
+()
diff --git a/testsuite/tests/ghci.debugger/scripts/all.T b/testsuite/tests/ghci.debugger/scripts/all.T
index 28089a2..b74a6ea 100644
--- a/testsuite/tests/ghci.debugger/scripts/all.T
+++ b/testsuite/tests/ghci.debugger/scripts/all.T
@@ -87,3 +87,4 @@ test('T2740', normal, ghci_script, ['T2740.script'])
 test('getargs', normal, ghci_script, ['getargs.script'])
 test('T7386', normal, ghci_script, ['T7386.script'])
 test('T8557', normal, ghci_script, ['T8557.script'])
+test('T12458', normal, ghci_script, ['T12458.script'])



More information about the ghc-commits mailing list