Skip to content

Instantly share code, notes, and snippets.

@Tarrasch
Created October 24, 2013 14:45
Show Gist options
  • Select an option

  • Save Tarrasch/7138579 to your computer and use it in GitHub Desktop.

Select an option

Save Tarrasch/7138579 to your computer and use it in GitHub Desktop.
Stack Traces, why you such a *****?
-- version 1:
e = do print 1002
ba <- reifyStack'
print $ sizeofByteArray ba
printStackTrace ba
print $ 1 `div` 0
print 2002
-- gives:
Stack trace:
0: stg_bh_upd_frame_ret (at rts/Updates.cmm:86:1-91:2)
1: stg_bh_upd_frame_ret (at rts/Updates.cmm:86:1-91:2)
2: runMainIO (at libraries/base/GHC/TopHandler.lhs:67:35-71:67)
... 2 unknown frames ...
5: sFt_info (using SYMTAB: /home/arash/repos/ghc-prof/my/ReifyTest)
... 3 unknown frames ...
9: sFt_info (using SYMTAB: /home/arash/repos/ghc-prof/my/ReifyTest)
... 3 unknown frames ...
13: sFt_info (using SYMTAB: /home/arash/repos/ghc-prof/my/ReifyTest)
-- Version 2:
e = do print 1002
print $ 1 `div` 0
print 2002
-- gives:
Loading debug data...
Stack trace:
0: stg_bh_upd_frame_ret (at rts/Updates.cmm:86:1-91:2)
1: stg_bh_upd_frame_ret (at rts/Updates.cmm:86:1-91:2)
2: ltInteger (at libraries/integer-gmp/GHC/Integer/Type.lhs:340:1-343:66)
3: integerToString (at libraries/base/GHC/Show.lhs:477:1-552:35)
4: stg_upd_frame_ret (at rts/Updates.cmm:31:1-38:2)
5: writeBlocks (at libraries/base/GHC/IO/Handle/Text.hs:587:4-612:31)
6: stg_ap_v_ret (at rts/dist/build/AutoApply.cmm:8:1-92:2)
7: bindIO (at libraries/base/GHC/Base.lhs:609:61-609:77)
8: bindIO (at libraries/base/GHC/Base.lhs:609:61-609:77)
9: bindIO (at libraries/base/GHC/Base.lhs:609:61-609:77)
10: bindIO (at libraries/base/GHC/Base.lhs:609:61-609:77)
11: bindIO (at libraries/base/GHC/Base.lhs:609:61-609:77)
12: bindIO (at libraries/base/GHC/Base.lhs:609:61-609:77)
13: stg_catch_frame_ret (at rts/Exception.cmm:365:1-367:2)
As a procedural programmer this is extremely unintuitive. Why on earth is the stack *completly* different when you just do some successfully terminating actions before exactly the same crash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment