Ticket #1279 (closed defect: worksforme)

Opened 4 years ago

Last modified 4 years ago

segmentation fault in compiled program, involves gtk, selinux

Reported by: guest Owned by: somebody
Priority: normal Milestone: 0.13.0
Component: general (Gtk+, Glib) Version: 0.12.4
Keywords: segmentation fault, multithreading, selinux Cc: garrett.mitchener@…

Description (last modified by dmwit) (diff)

I wrote a multithreaded GUI program for a research project using gtk2hs, and it works fine on fedora 17, which uses ghc 7.0.4. It crashes almost as soon as it starts when compiled and run on fedora 18 (ghc 7.4.1). There's a message on the console that it was killed because of a segmentation fault and that's about all it tells me. I tracked down the code that causes crash, and it seems to happen because I add an action to the gtk loop:

timeoutAddFull action ...

and the crash happens when the action runs the first time. I thought it was a bug in ghc 7.4.1, because I found a bug report that talks about a crash involving STM and multithreading, and supposedly was fixed in 7.4.2. So I set up a virtual machine and installed fedora 18 then upgraded it to rawhide to try my program under 7.4.2. But, the same crash happens on my rawhide machine.

However, it happened that I had to disable selinux on my rawhide machine using the boot command line because something started going wrong, still not sure what (hey, it's rawhide). Now my program does not crash. I just tested this on my fedora 18 laptop (still ghc 7.4.1) using both the version compiled on fedora 18 and the files from where I compiled it on rawhide: when I disable selinux, my program runs fine, but when it's enabled (even if set to permissive rather than enforcing) my program seg faults.

There's nothing useful in /var/log/messages, no indication of what selinux is unhappy about. I did find this: http://www.haskell.org/pipermail/haskell-cafe/2007-August/031120.html but at least in that problem, there was a definite error message about memory mapping, and I'm not getting one.

So as best I can tell, ghc 7.4.1&2 must both be doing something strange, maybe marking some piece of memory as data instead of code, maybe when performing calls to gtk, maybe in building thunks for use by timeoutAddFull, and eventually triggering a security problem.

My original program is huge. The problem must be some unexpected interaction between ghc's newer run time systems, gtk, and selinux. I'm attaching the smallest test case I could concoct and the build command. When you run the resulting program, it does nothing for about 2 seconds, then the action to print "tick" runs, and it crashes.

I'm filing the bug here because it might be a problem in gtk2hs.

I also filed it here under ghc because it might be a problem in the run time system: http://hackage.haskell.org/trac/ghc/ticket/7629

Here's the minimal test case (couldn't attach the file in trac for some reason):

module Try1 where

import Graphics.UI.Gtk
main = do
  timeoutAddFull (putStrLn "tick" >> return True) priorityDefaultIdle 2000
  return ()

To build:

ghc --make Try1 -debug -threaded -main-is Try1.main

Change History

Changed 4 years ago by guest

By the way: I'm garrett.mitchener@…, forgot to add that when submitting the above ticket. (I tried to create an account, but the "verify" e-mail never came...)

Changed 4 years ago by dmwit

  • cc garrett.mitchener@… added
  • description modified (diff)

Changed 4 years ago by dmwit

  • description modified (diff)

Hm. I have Fedora 17 + GHC 7.6.1, and this program doesn't crash. I guess I'll actually have to put together a virtual machine with Fedora 18 on it.

Changed 4 years ago by dmwit

  • status changed from new to closed
  • resolution set to worksforme

I really can't reproduce this. I made a fresh VM with Fedora 18, grabbed GHC from Fedora's repositories, then cabal-installed gtk2hs-buildtools and gtk (not even using the latest code from the repository), and your test program ticks along just fine. Can you find anything else on your system that varies from a fresh install?

Note: See TracTickets for help on using tickets.