[GHC] #15729: Static GHCi can segfault when accessing .bss section in C

#15729: Static GHCi can segfault when accessing .bss section in C --------------------------------------+------------------------------- Reporter: watashi | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.6.1 Keywords: | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: GHCi crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+------------------------------- When an object file is statically linked, GHCi can return junk or segfault when trying to access data defined in .bss section via foreign call. {{{ watashi % ~/gao/ghc/inplace/bin/ghc-stage2 --info | grep Dynamic ,("Dynamic by default","NO") ,("GHC Dynamic","NO") watashi % cat bss.c int read_bss(int i) { static int bss[1 << 20]; return bss[i]; } watashi % ~/gao/ghc/inplace/bin/ghc-stage2 --interactive test.o GHCi, version 8.7.20180920: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/watashi/.ghci Prelude> :m + Foreign Foreign.C Prelude Foreign Foreign.C> foreign import ccall unsafe "read_bss" read_bss :: Int -> IO Int Prelude Foreign Foreign.C> read_bss 0 4294059519 Prelude Foreign Foreign.C> read_bss 1 65535 Prelude Foreign Foreign.C> mapM (read_bss . bit) [0 .. 19] zsh: segmentation fault (core dumped) ~/gao/ghc/inplace/bin/ghc-stage2 --interactive test.o }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15729 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15729: Static GHCi can segfault when accessing .bss section in C -------------------------------+-------------------------------------- Reporter: watashi | Owner: watashi Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.6.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Changes (by watashi): * owner: (none) => watashi -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15729#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15729: Static GHCi can segfault when accessing .bss section in C -------------------------------+-------------------------------------- Reporter: watashi | Owner: watashi Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.6.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Comment (by simonmar): I think this is the same as #781, one of the oldest bugs we still have open. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15729#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15729: Static GHCi can segfault when accessing .bss section in C -------------------------------+-------------------------------------- Reporter: watashi | Owner: watashi Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.6.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------+-------------------------------------- Comment (by watashi): @simonmar It's similar, but not exactly the same. I don't know how we can fix #781 with static link, but this one should be fixable by allocating the .bss section in the range of 2G with the object. I will send a fix. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15729#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15729: Static GHCi can segfault when accessing .bss section in C -------------------------------+-------------------------------------- Reporter: watashi | Owner: watashi Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.6.1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #781 | Differential Rev(s): Phab:D5219 Wiki Page: | -------------------------------+-------------------------------------- Changes (by watashi): * differential: => Phab:D5219 * related: => #781 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15729#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15729: Static GHCi can segfault when accessing .bss section in C
-------------------------------+--------------------------------------
Reporter: watashi | Owner: watashi
Type: bug | Status: new
Priority: normal | Milestone:
Component: GHCi | Version: 8.6.1
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64 (amd64)
Type of failure: GHCi crash | Test Case:
Blocked By: | Blocking:
Related Tickets: #781 | Differential Rev(s): Phab:D5219
Wiki Page: |
-------------------------------+--------------------------------------
Comment (by Ben Gamari

#15729: Static GHCi can segfault when accessing .bss section in C -------------------------------+-------------------------------------- Reporter: watashi | Owner: watashi Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: GHCi | Version: 8.6.1 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #781 | Differential Rev(s): Phab:D5219 Wiki Page: | -------------------------------+-------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed * milestone: => 8.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15729#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15729: Static GHCi can segfault when accessing .bss section in C
-------------------------------+--------------------------------------
Reporter: watashi | Owner: watashi
Type: bug | Status: closed
Priority: normal | Milestone: 8.8.1
Component: GHCi | Version: 8.6.1
Resolution: fixed | Keywords:
Operating System: Linux | Architecture: x86_64 (amd64)
Type of failure: GHCi crash | Test Case:
Blocked By: | Blocking:
Related Tickets: #781 | Differential Rev(s): Phab:D5219
Wiki Page: |
-------------------------------+--------------------------------------
Comment (by Ben Gamari

#15729: Static GHCi can segfault when accessing .bss section in C
-------------------------------+--------------------------------------
Reporter: watashi | Owner: watashi
Type: bug | Status: closed
Priority: normal | Milestone: 8.8.1
Component: GHCi | Version: 8.6.1
Resolution: fixed | Keywords:
Operating System: Linux | Architecture: x86_64 (amd64)
Type of failure: GHCi crash | Test Case:
Blocked By: | Blocking:
Related Tickets: #781 | Differential Rev(s): Phab:D5219
Wiki Page: |
-------------------------------+--------------------------------------
Comment (by Ben Gamari
participants (1)
-
GHC