Re: [GHC] #7655: 7.6.2 Segmentation Fault/Bus Error in large exponentation

#7655: 7.6.2 Segmentation Fault/Bus Error in large exponentation
-------------------------------------+----------------------------------
Reporter: Doug310 | Owner:
Type: bug | Status: infoneeded
Priority: normal | Milestone: 7.8.4
Component: GHCi | Version: 7.8.1-rc1
Resolution: | Keywords: exponentiation
Operating System: MacOS X | Architecture: x86_64 (amd64)
Type of failure: GHCi crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Revisions: |
-------------------------------------+----------------------------------
Comment (by croyd):
Hi, I think I ran in to this issue running the following code (fibonacci
matrix exponentiation) in ghci. It seems to happen every single time I
execute it inside ghci, but never when using the full compiler (ghc
--make).
{{{#!hs
module Matrix where
data Matrix = Matrix Integer Integer Integer Integer deriving (Eq, Show)
instance Num Matrix where
fromInteger n = Matrix n n n n
negate = undefined
(+) = plusMatrix
(*) = mulMatrix
abs (Matrix a00 a01 a10 a11) = Matrix a00' a01' a10' a11'
where
a00' = abs a00
a01' = abs a01
a10' = abs a10
a11' = abs a11
signum = undefined
plusMatrix :: Matrix -> Matrix -> Matrix
(Matrix a00 a01 a10 a11) `plusMatrix` (Matrix b00 b01 b10 b11) =
Matrix (a00 + b00) (a01 + b01) (a10 + b10) (a11 + b11)
mulMatrix :: Matrix -> Matrix -> Matrix
(Matrix a00 a01 a10 a11) `mulMatrix` (Matrix b00 b01 b10 b11) =
Matrix a00' a01' a10' a11'
where
a00' = a00 * b00 + a01 * b10
a01' = a00 * b01 + a01 * b11
a10' = a10 * b00 + a11 * b10
a11' = a10 * b10 + a11 * b11
fib4 :: Integer -> Integer
fib4 0 = 0
fib4 n = case f ^ n of
Matrix _ fn _ _ -> fn
where
f = Matrix 1 1
1 0
main = do
print $ fib4 1000 -- ok
putStrLn $ replicate 80 '-'
print $ fib4 10000 -- ok
putStrLn $ replicate 80 '-'
print $ fib4 1000000 -- bus error: 10
}}}
crash report:
{{{
Process: ghc [30070]
Path: /usr/local/lib/ghc-7.8.3/bin/ghc
Identifier: ghc
Version: ???
Code Type: X86-64 (Native)
Parent Process: bash [97679]
User ID: 501
Date/Time: 2014-07-27 15:30:12.594 -0500
OS Version: Mac OS X 10.8.4 (12E55)
Report Version: 10
Crashed Thread: 1
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000115341000
VM Regions Near 0x115341000:
MALLOC metadata 000000011532c000-0000000115341000 [ 84K]
rw-/rwx SM=COW
--> MALLOC guard page 0000000115341000-0000000115342000 [ 4K]
---/rwx SM=NUL
Stack 0000000115342000-0000000115343000 [ 4K]
---/rwx SM=NUL
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff8d3340fa __psynch_cvwait
+ 10
1 libsystem_c.dylib 0x00007fff8d853fe9
_pthread_cond_wait + 869
2 libHSrts_thr-ghc7.8.3.dylib 0x00000001152bde86 waitCondition +
6
3 libHSrts_thr-ghc7.8.3.dylib 0x0000000115297752 yieldCapability
+ 354
4 libHSrts_thr-ghc7.8.3.dylib 0x00000001152a7f26 schedule + 502
5 libHSrts_thr-ghc7.8.3.dylib 0x00000001152a7d17
scheduleWaitThread + 167
6 libHSrts_thr-ghc7.8.3.dylib 0x00000001152a3eea hs_main + 138
7 ghc 0x000000010e8c6d73 main + 115
8 ghc 0x000000010e7ddc34 start + 52
Thread 1 Crashed:
0 libHSinteger-gmp-0.5.1.0-ghc7.8.3.dylib 0x0000000115178811
__gmpn_addlsh2_n + 289
1 libHSinteger-gmp-0.5.1.0-ghc7.8.3.dylib 0x00000001151b87aa
__gmpn_toom43_mul + 202
2 libHSinteger-gmp-0.5.1.0-ghc7.8.3.dylib 0x0000000115196c6b
__gmpn_mul + 1835
3 libHSinteger-gmp-0.5.1.0-ghc7.8.3.dylib 0x000000011519d795
__gmpn_tdiv_qr + 3221
4 libHSinteger-gmp-0.5.1.0-ghc7.8.3.dylib 0x00000001151b4b88
__gmpz_tdiv_qr + 408
5 libHSinteger-gmp-0.5.1.0-ghc7.8.3.dylib 0x0000000115175b9f
integer_cmm_quotRemIntegerzh + 207
6 libHSbase-4.7.0.1-ghc7.8.3.dylib 0x0000000114af08f0 c6Zm_info + 56
Thread 2:
0 libsystem_kernel.dylib 0x00007fff8d334f96 poll + 10
1 libHSbase-4.7.0.1-ghc7.8.3.dylib 0x0000000114be1444 cbep_info + 660
2 ??? 0x0000000115727e83 0 + 4654792323
Thread 3:
0 libsystem_kernel.dylib 0x00007fff8d334d16 kevent + 10
1 libHSbase-4.7.0.1-ghc7.8.3.dylib 0x0000000114ba3de5 cbpC_info + 173
2 libHSbase-4.7.0.1-ghc7.8.3.dylib 0x0000000114ba4908 cbuZ_info + 56
Thread 4:
0 libsystem_kernel.dylib 0x00007fff8d3340fa __psynch_cvwait
+ 10
1 libsystem_c.dylib 0x00007fff8d853fe9
_pthread_cond_wait + 869
2 libHSrts_thr-ghc7.8.3.dylib 0x00000001152bde86 waitCondition +
6
3 libHSrts_thr-ghc7.8.3.dylib 0x0000000115297752 yieldCapability
+ 354
4 libHSrts_thr-ghc7.8.3.dylib 0x00000001152a7f26 schedule + 502
5 libHSrts_thr-ghc7.8.3.dylib 0x00000001152a88bd scheduleWorker
+ 13
6 libsystem_c.dylib 0x00007fff8d84f7a2 _pthread_start
+ 327
7 libsystem_c.dylib 0x00007fff8d83c1e1 thread_start +
13
Thread 1 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x000000000000045b rcx:
0xfffffffffffffe84 rdx: 0x00000001154a0b68
rdi: 0x0000000115341bd0 rsi: 0x000000011549c5b8 rbp:
0x0000000115338f40 rsp: 0x0000000115338ec8
r8: 0x0000000000000001 r9: 0x0000000000000003 r10:
0x0000000000000003 r11: 0x0000000000000003
r12: 0xa37d223548939bc0 r13: 0x45cb5efb1fce45fd r14:
0x1ad82f94a68b146b r15: 0xaef755979088a4bb
rip: 0x0000000115178811 rfl: 0x0000000000010286 cr2:
0x0000000115341000
Logical CPU: 2
Binary Images:
0x10e7dc000 - 0x10e8cafff +ghc (???)
<515FEFFC-8563-3E63-A019-2D36A4E5B376> /usr/local/lib/ghc-7.8.3/bin/ghc
0x10e98f000 - 0x10ea80ff7
+libHShaskeline-0.7.1.2-ghc7.8.3.dylib (0)
<77838A66-EC3D-3443-AA05-484564631E96>
/usr/local/lib/ghc-7.8.3/haskeline-0.7.1.2/libHShaskeline-0.7.1.2-ghc7.8.3.dylib
0x10eb8e000 - 0x10eba8fff
+libHSterminfo-0.4.0.0-ghc7.8.3.dylib (0)
<F7B1336A-D768-35FB-A956-611BED7E9B16>
/usr/local/lib/ghc-7.8.3/terminfo-0.4.0.0/libHSterminfo-0.4.0.0-ghc7.8.3.dylib
0x10ebd8000 - 0x111533ff7 +libHSghc-7.8.3-ghc7.8.3.dylib (0)
<7496A043-6E06-3D38-9E0C-86B2F1443163>
/usr/local/lib/ghc-7.8.3/ghc-7.8.3/libHSghc-7.8.3-ghc7.8.3.dylib
0x112fe9000 - 0x113037ffe
+libHStransformers-0.3.0.0-ghc7.8.3.dylib (0) <760D119E-6E9D-3958-8EBD-
5FD0AE08F661>
/usr/local/lib/ghc-7.8.3/transformers-0.3.0.0/libHStransformers-0.3.0.0-ghc7.8.3.dylib
0x1130d0000 - 0x113217ffb +libHStemplate-
haskell-2.9.0.0-ghc7.8.3.dylib (0) <07A381B5-881A-34E7-A336-ED1E94B69C3D>
/usr/local/lib/ghc-7.8.3/template-haskell-2.9.0.0/libHStemplate-
haskell-2.9.0.0-ghc7.8.3.dylib
0x1133a2000 - 0x1133b9ff8 +libHShpc-0.6.0.1-ghc7.8.3.dylib
(0) <90B745B0-63A3-3339-8D3C-1D0864FFB3ED>
/usr/local/lib/ghc-7.8.3/hpc-0.6.0.1/libHShpc-0.6.0.1-ghc7.8.3.dylib
0x1133e0000 - 0x113427fff
+libHShoopl-3.10.0.1-ghc7.8.3.dylib (0) <40C41B4C-9A7B-3179-876C-
648C08E50D0C>
/usr/local/lib/ghc-7.8.3/hoopl-3.10.0.1/libHShoopl-3.10.0.1-ghc7.8.3.dylib
0x11349a000 - 0x1134abffe +libHSbin-package-
db-0.0.0.0-ghc7.8.3.dylib (0) <3C63EAE8-C8F7-3E49-845E-51BB912CAD10>
/usr/local/lib/ghc-7.8.3/bin-package-db-0.0.0.0/libHSbin-package-
db-0.0.0.0-ghc7.8.3.dylib
0x1134be000 - 0x113510ff9
+libHSbinary-0.7.1.0-ghc7.8.3.dylib (0) <19FB0D1E-CADF-369D-AB5F-
EFE63DB78B47>
/usr/local/lib/ghc-7.8.3/binary-0.7.1.0/libHSbinary-0.7.1.0-ghc7.8.3.dylib
0x11355d000 - 0x113b35ffe
+libHSCabal-1.18.1.3-ghc7.8.3.dylib (0) <6E368272-1A7F-
3C57-AAB0-4EBFC9AB09B2>
/usr/local/lib/ghc-7.8.3/Cabal-1.18.1.3/libHSCabal-1.18.1.3-ghc7.8.3.dylib
0x114104000 - 0x114113fff
+libHSprocess-1.2.0.0-ghc7.8.3.dylib (0)
participants (1)
-
GHC