[GHC] #14634: Add print stacktrace to exception handler in runtime system
GHC
ghc-devs at haskell.org
Thu Jan 4 11:04:04 UTC 2018
#14634: Add print stacktrace to exception handler in runtime system
-------------------------------------+-------------------------------------
Reporter: flip101 | Owner: (none)
Type: feature | Status: new
request |
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.2
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
{{{#!hs
main :: IO ()
main = do
someIO
putStrLn "hello world"
someIO :: IO ()
someIO = ioError $ IOError Nothing IllegalOperation "a" "b" Nothing
Nothing
}}}
This code prints the following
{{{
exception: a: illegal operation (b)
}}}
I think there is something in the runtime system which takes this
exception and prints this text to the terminal. I will call this the
"runtime exception handler" (for i don't know any better).
{{{#!hs
main :: IO ()
main = do
ex <- try someIO :: IO (Either IOException ())
case ex of
Left e -> error (show e)
Right _ -> putStrLn "hello world"
someIO :: IO ()
someIO = ioError $ IOError Nothing IllegalOperation "a" "b" Nothing
Nothing
}}}
output:
{{{
exception: a: illegal operation (b)
CallStack (from HasCallStack):
error, called at src/Main.hs:10:15 in main:Main
}}}
Now i use an explicit handler in my code and show the stacktrace with
`error`. Could this handler be moved into the RTS so that i can
stacktraces with exceptions just like with error?
I think this issue is related to, but not the same as
https://ghc.haskell.org/trac/ghc/ticket/12096 Because "Attach stacktrace
information to SomeException" -- whatever there is being attached right
now (with lts-10.2 ghc 8.2.2) is good enough to provide the information,
it's just the print option in the handler that seems to be missing.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14634>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list