RE: Examining the Haskell stack (read at your own risk ; -))
On 02 December 2005 14:03, Joel Reymont wrote:
You told me a bit about how to examine the Haskell stack by looking at R22 on the PowerPC and $ebx on Intel architectures. I looked at your .gdbinit but could not figure out which macros are to be used.
The example below is a bit contrived in that I'm freeing the SSL context twice, on purpose. I tried getting a disassembler dump using the contents of R22 without luck:
(gdb) info registers r22 r22 0x137a3cc 20423628 (gdb) disas 0x137a3cc No function contains specified address.
This is my stack trace:
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000019 0x00568fe0 in sk_pop_free () (gdb) where #0 0x00568fe0 in sk_pop_free () #1 0x0059f128 in X509_VERIFY_PARAM_free () #2 0x003c4d5c in SSL_free () #3 0x000c3254 in r7cH_info () #4 0x000ccd04 in schedule (mainThread=0x13f3f18, initialCapability=0x578df0) at Schedule.c:932 #5 0x000cdcac in waitThread_ (m=0x1100360, initialCapability=0x0) at Schedule.c:2156 #6 0x000cdb90 in scheduleWaitThread (tso=0x13c0000, ret=0x0, initialCapability=0x0) at Schedule.c:2050 #7 0x0001ff0c in rts_evalLazyIO (p=0x1ce0c8, ret=0x0) at RtsAPI.c:459 #8 0x0000495c in main (argc=25, argv=0x578df0) at Main.c:104 (gdb) info registers r22 r22 0x137a3cc 20423628 (gdb) disas 0x137a3cc No function contains specified address.
It looks like your crash happened in the SSL library, and you have a useful stack trace there. r22 is a pointer to the stack, not a pointer to code, so you can't disassemble it, you need to display memory (as I described in separate mail). Cheers, Simon
On Dec 2, 2005, at 2:08 PM, Simon Marlow wrote:
It looks like your crash happened in the SSL library, and you have a useful stack trace there.
This is contrived in that I already know where the error is and it clearly points to SSL_free. I'm trying to figure out how I would have gotten to that call to getHostByName.
r22 is a pointer to the stack, not a pointer to code, so you can't disassemble it, you need to display memory (as I described in separate mail).
Quoting you: --- gdb> p16 $r22 which prints 16 words of memory backwards (the way I like it) starting at the addresss in $r22. when displaying memory this way, gdb very handily prints the symbol name for words that point into the program. You can then pick things off the stack that look like return addresses and disassemble them, if you want. --- And p16 is defined in .gdbinit as: define p16 pmem $arg0 16 end Printing the 16 words gives me the printout below but where do I find my Haskell function? The code tha causes the crash looks like this: maybeFreeSSL :: MaybeSSL -> IO () maybeFreeSSL tmv = do putStrLn $ "maybeFreeSSL invoked" mssl <- atomically $ swapTMVar tmv Nothing case mssl of Nothing -> return () Just (ssl, _, _) -> do sslFree ssl sslFree ssl Is there a way to have maybeFreeSSL in the trace? I compiled the app with -debug but the libraries and the above maybeFreeSSL code was compiled without it. Thanks, Joel P.S. Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000019 0x00568fe0 in sk_pop_free () (gdb) p16 $r22 0x137a40c: 0x1ce63c <stg_NO_TREC_closure> 0x137a408: 0x0 0x137a404: 0x0 0x137a400: 0x18fd0 <stg_TREC_HEADER_info> 0x137a3fc: 0xd6dbc <stg_stop_thread_info> 0x137a3f8: 0xd6f38 <stg_noforceIO_info> 0x137a3f4: 0x13ef148 0x137a3f0: 0x0 0x137a3ec: 0x2605c <stg_catch_frame_info> 0x137a3e8: 0x25c80 <stg_unblockAsyncExceptionszh_ret_info> 0x137a3e4: 0x13ef150 0x137a3e0: 0x27030 <s3BN_info> 0x137a3dc: 0x1d22cc <GHCziConc_lvl7_closure> 0x137a3d8: 0x26f6c <s3BK_info> 0x137a3d4: 0x13f38f4 0x137a3d0: 0x243f4 <s7Fy_info> 0x137a3cc: 0xc3270 <s7FI_info> -- http://wagerlabs.com/
participants (2)
-
Joel Reymont -
Simon Marlow