[GHC] #11829: C++ does not catch exceptions when used with Haskell-main and linked by ghc

GHC ghc-devs at haskell.org
Sat Jul 21 10:36:01 UTC 2018


#11829: C++ does not catch exceptions when used with Haskell-main and linked by ghc
-------------------------------------+-------------------------------------
        Reporter:  pl                |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Runtime System    |              Version:  7.10.3
      Resolution:                    |             Keywords:  c++
                                     |  exceptions
Operating System:  MacOS X           |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Runtime crash     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by syntheorem):

 I just ran into this, but the `-lto_library` flag didn't fix the problem
 (Clang is passing it automatically now anyway). What ultimately worked for
 me was adding `-Wl,-keep_dwarf_unwind` to my `ld-options`.

 I tried your method of writing `main` in C++ and manually linking via
 Clang to see what it does. Interestingly, just linking against the Haskell
 libraries and RTS with no other flags broke exceptions for me. But I also
 got the same warning:
 {{{
 ld: warning: could not create compact unwind for _ffi_call_unix64: does
 not use RBP or RSP based frame
 }}}
 I searched for that  and discovered that you could use
 `-Wl,-no_compact_unwind` to disable the warning; and GHC already passes
 that flag to Clang during linking. But that option also somehow breaks the
 exception handling tables; the system will fall back on the DWARF
 exception tables if you include them by passing `-Wl,-keep_dwarf_unwind`.

 Also worth noting that I'm on macOS 10.12.6, which is about a year out of
 date, so the issue might be fixed on the most recent version. Using GHC
 8.4.3 and Clang 6.0.1.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11829#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list