[GHC] #12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers --------------------------------------+---------------------------------- Reporter: geraint | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Keywords: | Operating System: MacOS X Architecture: x86_64 (amd64) | Type of failure: Runtime crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+---------------------------------- In ghci 8.0.1 on my mac, expressions no bigger than {{{2^(10^7) :: Integer}}} usually cause a bus error; {{{2^(10^6)}}} is apparently OK. The force of "usually" is that every now and then they and larger expressions are fine, so it is not quite reproducible. I believe it's the Integer arithmetic library, rather than the exponentiation, and I think it might be a stack overflow in libHSinteger- gmp-1.0.0.1-ghc8.0.1.dylib The problem was first encountered with compiled code doing additions and multiplications on similarly sized Integer values. Substantially larger numbers can be handled by 7.8.4 on other platforms, which is all I have to compare it with. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers ----------------------------------+-------------------------------------- Reporter: geraint | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by bgamari): Indeed I can reproduce this on our Mac Mini but sadly can't convince `lldb` to attach to the compiler. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers ----------------------------------+-------------------------------------- Reporter: geraint | Owner: Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * cc: hvr (added) * priority: normal => high * milestone: => 8.2.1 Comment: Alright, here's a backtrace, {{{ ghc-mini:~ bgamari$ sudo lldb -- /Users/bgamari/ghc-8.0.1/lib/ghc-8.0.1/bin/ghc -B/Users/bgamari/ghc-8.0.1/lib/ghc-8.0.1 --interactive Password: (lldb) target create "/Users/bgamari/ghc-8.0.1/lib/ghc-8.0.1/bin/ghc" run Current executable set to '/Users/bgamari/ghc-8.0.1/lib/ghc-8.0.1/bin/ghc' (x86_64). (lldb) settings set -- target.run-args "-B/Users/bgamari/ghc-8.0.1/lib/ghc-8.0.1" "--interactive" (lldb) run Process 99769 launched: '/Users/bgamari/ghc-8.0.1/lib/ghc-8.0.1/bin/ghc' (x86_64) GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Prelude> 2^(10^7) :: Integer Process 99769 stopped * thread #2: tid = 0x6cc7f82, 0x0000000108169cfd libHSinteger- gmp-1.0.0.1-ghc8.0.1.dylib`__gmpn_mul + 3437, stop reason = EXC_BAD_ACCESS (code=1, address=0x70000d43ad38) frame #0: 0x0000000108169cfd libHSinteger- gmp-1.0.0.1-ghc8.0.1.dylib`__gmpn_mul + 3437 libHSinteger-gmp-1.0.0.1-ghc8.0.1.dylib`__gmpn_mul: -> 0x108169cfd <+3437>: callq 0x10818d6a0 ; __gmpn_toom63_mul 0x108169d02 <+3442>: jmp 0x10816975f ; <+1999> 0x108169d07 <+3447>: movq -0x118(%rbp), %rcx 0x108169d0e <+3454>: movq -0x158(%rbp), %rdx (lldb) bt * thread #2: tid = 0x6cc7f82, 0x0000000108169cfd libHSinteger- gmp-1.0.0.1-ghc8.0.1.dylib`__gmpn_mul + 3437, stop reason = EXC_BAD_ACCESS (code=1, address=0x70000d43ad38) * frame #0: 0x0000000108169cfd libHSinteger- gmp-1.0.0.1-ghc8.0.1.dylib`__gmpn_mul + 3437 frame #1: 0x0000000108169df5 libHSinteger- gmp-1.0.0.1-ghc8.0.1.dylib`__gmpn_mul + 3685 frame #2: 0x00000001081701aa libHSinteger- gmp-1.0.0.1-ghc8.0.1.dylib`__gmpn_tdiv_qr + 2986 frame #3: 0x0000000108145742 libHSinteger- gmp-1.0.0.1-ghc8.0.1.dylib`crUO_info + 50 }}} hvr, do you have any idea what is going on here? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers ----------------------------------+-------------------------------------- Reporter: geraint | Owner: Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by rwbarton): It's probably the same issue as #7655. See ticket:7655#comment:33 specifically. What version of libgmp are you using? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers ----------------------------------+-------------------------------------- Reporter: geraint | Owner: Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by George): FWIW, on my Mac it resulted in "your system has run out of Application Memory" and I had to reboot my machine. this is with ghc 8.0.1 and Mac OS 10.12.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers ----------------------------------+-------------------------------------- Reporter: geraint | Owner: Type: bug | Status: infoneeded Priority: high | Milestone: 8.2.1 Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by rwbarton): * status: new => infoneeded -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers ----------------------------------+-------------------------------------- Reporter: geraint | Owner: Type: bug | Status: infoneeded Priority: high | Milestone: 8.2.1 Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by geraint): I presume this means "What version of libgmp are you using?" and is directed at me. No idea, before you asked I wasn't aware of libgmp: how do I tell? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers ----------------------------------+-------------------------------------- Reporter: geraint | Owner: Type: bug | Status: infoneeded Priority: high | Milestone: 8.2.1 Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by rwbarton): A good question. I don't have a Mac but I think you can do the following. * Run `less $(which ghc)`. The second line should be of the form `exedir=".../bin"`. * Run `otool -L .../bin/ghc` using the path from above. Look for a line mentioning `libgmp`. `otool -l` might also have useful information. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers ----------------------------------+-------------------------------------- Reporter: geraint | Owner: Type: bug | Status: infoneeded Priority: high | Milestone: 8.2.1 Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by geraint): Running otool only tells me about libHSinteger-gmp, specifically: @rpath/libHSinteger-gmp-1.0.0.1-ghc8.0.1.dylib (compatibility version 0.0.0, current version 0.0.0) but I edited an earlier comment (which apparently doesn't generate an email): "... by dint of looking at HsIntegerGmp.h I see it is 5.0.4 and GHC_GMP_INTREE is true, so it is the presumably the allocation bug in gmp." This is how it comes for the Mac in the current Haskell platform. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers ----------------------------------+-------------------------------------- Reporter: geraint | Owner: Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by rwbarton): * status: infoneeded => new Comment: Aha, I missed the part about `GHC_GMP_INTREE` being true. Then yes, I'll close this as a duplicate of #7655. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12954: unexpected uncaught segmentation error in arbitrary precision Integer calculations with modestly large numbers ----------------------------------+-------------------------------------- Reporter: geraint | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: GHCi | Version: 8.0.1 Resolution: duplicate | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: #7655 | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by rwbarton): * status: new => closed * resolution: => duplicate * related: => #7655 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12954#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC