[GHC] #15260: Xmobar crashes with segmentation fault

#15260: Xmobar crashes with segmentation fault --------------------------------------+---------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 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: --------------------------------------+---------------------------------- OS: Arch Kernel version: 4.16.13-2-ARCH Xmobar version: 0.26 ghc version: 8.4.3 Xmobar crashes after some time (1 sec or 1 day - very different each time). And, as I see, reasons are different to: 1: {{{ voronwe@sul ~> xmobar Fields missing from config defaulted: additionalFonts,wmClass,wmName,border,borderColor,textOffset,iconOffset,iconRoot,alpha xmobar: internal error: evacuate: strange closure type 4689 (GHC version 8.4.3 for x86_64_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug fish: 'xmobar' terminated by signal SIGABRT (Abort) }}} 2: {{{ voronwe@sul ~> xmobar Fields missing from config defaulted: additionalFonts,wmClass,wmName,border,borderColor,textOffset,iconOffset,iconRoot,alpha fish: 'xmobar' terminated by signal SIGSEGV (Address boundary error) }}} See my issue on xmobar github for details: https://github.com/jaor/xmobar/issues/354 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 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): Thanks for reporting. I tried running `xmobar` with your config but couldn't reproduce this (Ubuntu 18.04, x86_64). Could you try running xmobar using the debug runtime with sanity checks enabled and tell us if you get a different error? Add `-rtsopts -debug` to `ghc-options` in `xmobar.cabal`, and then run `xmobar` as `xmobar +RTS -DS`. To make sure you're running with the expected runtime check `xmobar +RTS --info`, the `RTS way` should be `rts_debug`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 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): With the help of other users I managed to get a backtrace. More details are in the [https://github.com/jaor/xmobar/issues/354#issuecomment-396356426 Github thread]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 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): * version: 8.4.3 => 8.5 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault
----------------------------------+--------------------------------------
Reporter: Voronwe | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.5
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):
I wonder if this is a FFI misuse in X11 or xmobar. A `XNextEvent` FFI call
overrides an info table pointer:
{{{
Hardware watchpoint 2: ((StgClosure*)0x4200029f90)->header.info
Old value = (const StgInfoTable *) 0x0
New value = (const StgInfoTable *) 0xcfe1f0
bt #0 0x00007fdcd3143927 in XNextEvent () from /usr/lib/x86_64-linux- gnu/libX11.so.6 #1 0x000000000041385c in XUtil_zdwnextEventzq_info () #2 0x0000000000000011 in ?? () #3 0x0000000000000000 in ?? () }}}
(because this is reverse-execution new and old values are swapped, so old value is actually the new value being written by XNextEvent) Before overriding the info table ptr the object is the string `" "`: {{{
call printClosure(0x4200029f90) ghc-prim:GHC.Types.:(0xfa1501, 0xfa02e9) call printClosure(0xfa1501) ghc-prim:GHC.Types.C#(0x32#) call printClosure(0xfa02e9) ghc-prim:GHC.Types.[](0xcfdac8#) }}}
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.5 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 duncancmt): This bug has a ticket open on the Arch tracker https://bugs.archlinux.org/task/58795 . I have had no luck coming up with a reliable way to reproduce this behavior. I'm sure you've already seen these, but #14346 and #13707 seem possibly related to this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.5 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 dschrempf): Just wanted to add that the crash can be reliably induced by moving floating windows over the bar. {{{ Jul 16 14:56:18 schwarzbaer systemd-coredump[3993]: Process 3929 (xmobar) of user 1000 dumped core. Stack trace of thread 3929: #0 0x00007f8c410892b8 n/a (libHSrts-ghc8.4.3.so) #1 0x00007f8c410885dd n/a (libHSrts-ghc8.4.3.so) #2 0x00007f8c4109f3a4 n/a (libHSrts-ghc8.4.3.so) #3 0x00007f8c410a5c2b n/a (libHSrts-ghc8.4.3.so) #4 0x00007f8c4108e00d n/a (libHSrts-ghc8.4.3.so) #5 0x00007f8c4108ed0a scheduleWaitThread (libHSrts-ghc8.4.3.so) #6 0x00007f8c4109c8dc hs_main (libHSrts-ghc8.4.3.so) #7 0x000000000058adff n/a (xmobar) #8 0x00007f8c4078106b __libc_start_main (libc.so.6) }}} #9 0x00000000004300ba n/a (xmobar) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.5 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): Someone reported on another github issue (and I've also confirmed) that the segfault disappears when compiled with GHC 8.2.2. Not sure if important but versions of dependencies are different with GHC 8.4.2 and 8.2.2: - directory-1.3.3.0 in 8.4.2, directory-1.3.0.2 in 8.2.2 - process-1.6.3.0 in 8.4.2, process-1.6.1.0 in 8.2.2 - stm-2.5.0.0 in 8.4.2, stm-2.4.5.0 in 8.2.2 - unix-2.8.0.0 in 8.4.2, unix-2.7.2.2 in 8.2.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.5 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): I was posting my updates to the Github thread but I think this is a better place for them so moving those here and post future updates here as well. Two interesting finds: - The segfault is very easy to trigger when I add `performMajorGC`s around xmobar's `nextEvent'`: {{{ diff --git a/src/XUtil.hsc b/src/XUtil.hsc index 9063147..97f4961 100644 --- a/src/XUtil.hsc +++ b/src/XUtil.hsc @@ -39,6 +39,7 @@ import Graphics.X11.Xlib.Extras import System.Mem.Weak ( addFinalizer ) import System.Posix.Types (Fd(..)) import System.IO +import System.Mem (performMajorGC) #if defined XFT || defined UTF8 # if __GLASGOW_HASKELL__ < 612 @@ -207,8 +208,9 @@ newWindow dpy scr rw (Rectangle x y w h) o = do nextEvent' :: Display -> XEventPtr -> IO () nextEvent' d p = do pend <- pending d + performMajorGC if pend /= 0 - then nextEvent d p + then nextEvent d p >> performMajorGC else do threadWaitRead (Fd fd) nextEvent' d p }}} - If I compile xmobar with `-O0` I can't reproduce the segfault. (by default it's compiled with `-O1`) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.5 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 incertia): Replying to [comment:9 osa1]:
Two interesting finds:
It is also interesting to note that running it under `valgrind` also makes the segfault disappear. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.5 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): I get the same kind of segfault with GHC 8.4.3 in another program unrelated to xmobar. Sadly it's not simpler as it's a standalone static program that runs directly on top of Linux in a ramdisk (using [http://haskus.org/system haskus-system])... Hence I can't use any tool like valgrind or gdb. Anyway one good thing is that it fails invariably within a few seconds and here is what I've found: 1) The segfault occurs [https://phabricator.haskell.org/diffusion/GHC/browse/ghc-8.4/rts/sm/Evac.c$6... here] because `info` is garbage (sometimes 0). 2) Recompiling with `-debug -with-rtsopts=-DS`, I get: {{{ Clock2: internal error: checkClosure (closure type 62) (GHC version 8.4.3 for x86_64_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} because of a bug [https://phabricator.haskell.org/rGHC9976bed24dda9449ac2e3e95fb4bf8b379114a28 fixed in 8.6]. After cherry-picking this commit into ghc-8.4.3, `-DS` doesn't report anything useful (nor do the other `-D*` flags). 3) Using `-V0` or `-C0` delays the segfault. 4) Same bug with GHC 8.4.2 I'll try to find the commit introducing the regression. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.5 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): Finally I think this is a duplicate of #14346 because fixing it (again) solves the issue I had in comment:11. Voronwe: You should check if it fixes it for you too. We can close this ticket if it does. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.5 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 that the fix for #14346 (Phab:D5020) fixes this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.5 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 Voronwe): Can you help me? I'm a bit confused... Where can I obtain source code of ghc ''with'' this fix? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.5 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): The easiest way is to use arcanist to download the patch from https://phabricator.haskell.org/D5020 (i.e. execute "arc patch D5020" in a Git checkout of GHC). But comment:13 already confirmed the fix so you don't have to bother. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 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): * milestone: 8.8.1 => 8.6.1 Comment: We all owe hsyl20 a debt of gratitude for taking the time to get to the bottom of this. Thanks to him the fix will be present in 8.6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 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): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed Comment: Fix was merged to `ghc-8.6` in 3ec1d931218e603ba1622faa2b52884b2477a7db and `master` in 56590db07a776ce81eb89d4a4d86bd0f953fb44e. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15260: Xmobar crashes with segmentation fault ----------------------------------+-------------------------------------- Reporter: Voronwe | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.4.4 Component: Compiler | Version: 8.5 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): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * milestone: 8.6.1 => 8.4.4 Comment: Merged to `ghc-8.4` in 56590db07a776ce81eb89d4a4d86bd0f953fb44e. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15260#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC