Opened 10 years ago

Closed 10 years ago

#3821 closed merge (fixed)

Trace.Hpc.Reflect.examineTix segfaults on 64bit

Reported by: TristanAllwood Owned by: igloo
Priority: high Milestone: 6.12.2
Component: Code Coverage Version: 6.12.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: x86_64 (amd64)
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The following seg-faults on my 64bit ghc 6.12.1 when compiled with -fhpc

module Main where

import B
import Trace.Hpc.Reflect

main :: IO ()
main = do
  examineTix
  print (foo 3)
  return ()
module B where

foo 0 = 0
foo n = 1 + foo (n-1)
>ghc --make -fforce-recomp -fhpc Main
[1 of 2] Compiling B                ( B.hs, B.o )
[2 of 2] Compiling Main             ( Main.hs, Main.o )
Linking Main ...

10:21:55 - tora@colorado:/tmp/HPC
>./Main 
Segmentation fault

I believe the cause is that data ModuleInfo = ModuleInfo String Int Hash (Ptr Word64) in Trace.Hpc.Reflect uses a variable sized Int instead of a fixed (32bit if I'm reading the sources correctly) Word32 for the count.

I've attached a patch that should fix the issue.

Change History (5)

comment:1 Changed 10 years ago by TristanAllwood

Trac is failing to let me add the patch file - it's smallish so here it is inline...

Fri Jan 15 10:21:41 GMT 2010  tora@zonetora.co.uk
  * Use a fixed size value when reading from Memory for ModuleInfo's

New patches:

[Use a fixed size value when reading from Memory for ModuleInfo's
tora@zonetora.co.uk**20100115102141
 Ignore-this: a7cef3dacbb29c22a12f654c616f500e
] {
hunk ./Trace/Hpc/Reflect.hsc 43
       ptr <- hs_hpc_rootModule 
       moduleInfoList ptr
 
-data ModuleInfo = ModuleInfo String Int Hash (Ptr Word64) 
+data ModuleInfo = ModuleInfo String Word32 Hash (Ptr Word64) 
 
 moduleInfoList :: Ptr () -> IO [ModuleInfo]
 moduleInfoList ptr
hunk ./Trace/Hpc/Reflect.hsc 60
 
 clearTix :: IO ()
 clearTix = do
-      sequence_ [ pokeArray ptr $ take count $ repeat 0
+      sequence_ [ pokeArray ptr $ take (fromIntegral count) $ repeat 0
       	      	| ModuleInfo _mod count _hash ptr <- modInfo
 		]
       return ()
hunk ./Trace/Hpc/Reflect.hsc 68
 
 examineTix :: IO Tix
 examineTix = do
-      mods <- sequence [ do tixs <- peekArray count ptr
-      	      	       	    return $ TixModule mod' hash count
+      mods <- sequence [ do tixs <- peekArray (fromIntegral count) ptr
+      	      	       	    return $ TixModule mod' hash (fromIntegral count)
 			    	   $ map fromIntegral tixs
       	      	       | (ModuleInfo mod' count hash ptr) <- modInfo
 		       ]
hunk ./Trace/Hpc/Reflect.hsc 85
       	      	| (ModuleInfo mod1 count1 hash1 ptr,
 		   TixModule mod2 hash2 count2 tixs) <- zip modInfo modTixes
 		, if mod1 /= mod2 
-		|| count1 /= count2 
+		|| (fromIntegral count1) /= count2 
 		|| hash1 /= hash2
 		|| length tixs /= count2
 		  then error "updateTix failed"
}

Context:

[Fix quoting in the "tough" test
Ian Lynagh <igloo@earth.li>**20100102174643] 
[Fix quoting in more tests
Ian Lynagh <igloo@earth.li>**20100102174616] 
[Fix quoting in some hpc tests
Ian Lynagh <igloo@earth.li>**20100102174221] 
[Fix tests/hpcrun.pl to handle paths containing spaces
Ian Lynagh <igloo@earth.li>**20100102173344] 
[Bump version number
Ian Lynagh <igloo@earth.li>**20091219201528] 
[Remove unused test bits
Ian Lynagh <igloo@earth.li>**20091219195119] 
[Fix some more hpc tests
Ian Lynagh <igloo@earth.li>**20091219194957] 
[Fix some hpc tests
Ian Lynagh <igloo@earth.li>**20091219192808] 
[Comment that we need to fix cleaning the tests
Ian Lynagh <igloo@earth.li>**20091219164941] 
[Tweak some hpc tests
Ian Lynagh <igloo@earth.li>**20091215215405] 
[Fix some quoting problems in the tests
Ian Lynagh <igloo@earth.li>**20091209194903] 
[Whitespace only
Ian Lynagh <igloo@earth.li>**20091203134407] 
[Follow testsuite driver changes
Ian Lynagh <igloo@earth.li>**20091128185017] 
[Update dependencies
Ian Lynagh <igloo@earth.li>**20090920152421] 
[Bump version to 0.5.0.4
Ian Lynagh <igloo@earth.li>**20090920141921] 
[Fix unused import warnings
Ian Lynagh <igloo@earth.li>**20090707133640] 
[Remove unused imports
Ian Lynagh <igloo@earth.li>**20090707115847] 
[TAG 2009-06-25
Ian Lynagh <igloo@earth.li>**20090625160250] 
Patch bundle hash:
20b3a7d510206226e00ce3f8653484ba563f51ab

comment:2 Changed 10 years ago by simonmar

Milestone: 6.12.2
Priority: normalhigh

comment:3 Changed 10 years ago by simonmar

Owner: changed from andy@… to simonmar
Status: newassigned

I've validating.

comment:4 Changed 10 years ago by simonmar

Owner: changed from simonmar to igloo
Status: assignednew
Type: bugmerge

Patch applied (packages/hpc):

Fri Jan 15 10:21:41 GMT 2010  tora@zonetora.co.uk
  * Use a fixed size value when reading from Memory for ModuleInfo's

comment:5 Changed 10 years ago by igloo

Resolution: fixed
Status: newclosed

Merged as part of:

Wed Jan 27 08:03:07 PST 2010  Ian Lynagh <igloo@earth.li>
  * Update to new versions of hpc and old-time
Note: See TracTickets for help on using tickets.