[GHC] #15260: Xmobar crashes with segmentation fault

GHC ghc-devs at haskell.org
Tue Jul 24 07:11:37 UTC 2018


#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


More information about the ghc-tickets mailing list