[GHC] #15892: Segmentation fault with ByteString and -O

#15892: Segmentation fault with ByteString and -O --------------------------------------+---------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Keywords: | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: Runtime crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+---------------------------------- The attached program consistently segfaults (within a few seconds) when compiled with ghc-8.6.1 or ghc-8.6.2. It runs forever (as expected) when compiled with ghc-8.4. To reproduce: {{{ ghc segfault.hs }}} then, {{{ ./segfault >/dev/null }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString and -O ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by akio): * Attachment "segfault.hs" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString and -O ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by osa1): Confirmed on GHC HEAD. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString and -O ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by osa1): * cc: osa1, simonmar (added) Comment: This seems to be related with the GC. I realized two things: - If I run with debug runtime I get this error: {{{ segfault: internal error: Evaluated a CAF (0x851768) that was GC'd! (GHC version 8.7.20181113 for x86_64_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug zsh: abort (core dumped) ./segfault +RTS > /dev/null }}} - If I play around with GC params sometimes this programs can run for much longer. E.g. on my system `+RTS -A1G` or `+RTS -G5` seem to make the problem disappear. Could this be related with the recent SRT work? CCing simonmar. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString and -O ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by fumieval): Here's an equivalent code with bytestring operations unrolled: https://github.com/tsurucapital/segfault/blob/fumieval/app/Main.hs -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString and -O ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * priority: normal => highest Comment: Yikes, this looks awful. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString and -O ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by maoe): * cc: maoe (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by osa1): (You don't need -O for this, updating summary) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by Fuuzetsu): * cc: fuuzetsu (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by fumieval): * cc: fumieval (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by simonmar): I'm looking into this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by hsyl20): Could it be another manifestation of #14375? Maybe try to NOINLINE `withForeignPtr`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: patch Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5334 Wiki Page: | ----------------------------------+-------------------------------------- Changes (by simonmar): * status: new => patch * differential: => Phab:D5334 Comment: Thanks for the bug report @akio and for the very nice small test case @fumieval. I managed to further reduce the code and remove most of the Iteratee stuff, which was making the bug really hard to narrow down. I believe I've now found the problem, the fix was to add a pair of parentheses(!), see Phab:D5334. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: patch Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5334 Wiki Page: | ----------------------------------+-------------------------------------- Comment (by fumieval): Nice, that's amazingly fast! I confirmed that D5334 fixes the crash. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString
----------------------------------+--------------------------------------
Reporter: akio | Owner: (none)
Type: bug | Status: patch
Priority: highest | Milestone: 8.6.3
Component: Compiler | Version: 8.6.2
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64 (amd64)
Type of failure: Runtime crash | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5334
Wiki Page: |
----------------------------------+--------------------------------------
Comment (by Ömer Sinan Ağacan

#15892: Segmentation fault with ByteString ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: merge Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5334 Wiki Page: | ----------------------------------+-------------------------------------- Changes (by osa1): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15892: Segmentation fault with ByteString ----------------------------------+-------------------------------------- Reporter: akio | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5334 Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged with 4519d98d5399c2a958b2592b0ab50d89980d48b5. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15892#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC