Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

Print NaCl exception message + fault injection command

Open slipher opened this issue 1 year ago • 1 comments

Stacked (hehe) on #1063.

In #716 I removed the code for NaCl exception messages in favor of letting it crash with an nice stack trace. But we can have our cake and eat it too. Here's an example of an NaCl crash dump including the custom terminate handler (which logs the exception message), as well as the stack leading to the error below

Thread 0 (crashed)
 0  main.nexe!abort [abort.c : 21 + 0x0]
    rax = 0x0000000000000000   rdx = 0x0000000000000000
    rcx = 0x000000000ffc13e0   rbx = 0x0000000000000000
    rsi = 0x0000000000000000   rdi = 0x00000000fffe6d68
    rbp = 0x00000000fffeff80   rsp = 0x00000000fffe6d90
     r8 = 0x0000000000000000    r9 = 0x0000000000000000
    r10 = 0x0000000000000000   r11 = 0x000006e700582760
    r12 = 0x00000000fd3c4738   r13 = 0x00000000fffe6fa0
    r14 = 0x00000000fd3d97b0   r15 = 0x000006e700000000
    rip = 0x0000000000582796
    Found by: given as instruction pointer in context
 1  main.nexe!TerminateHandler() [VMMain.cpp : 141 + 0x20]
    rbx = 0x0000000000000002   rbp = 0x00000000fffeff80
    rsp = 0x00000000fffe6db0   r12 = 0x00000000fd3c4738
    r13 = 0x00000000fffe6fa0   r14 = 0x00000000fd3d97b0
    r15 = 0x000006e700000000   rip = 0x00000000001e7580
    Found by: call frame info
 2  main.nexe!std::__terminate(void (*)()) [cxa_handlers.cpp : 68 + 0x40]
    rbx = 0x00000000fd3d97d0   rbp = 0x00000000fffeff80
    rsp = 0x00000000fffe6df0   r12 = 0x00000000fd3c4738
    r13 = 0x00000000fffe6fa0   r14 = 0x00000000fd3d97b0
    r15 = 0x000006e700000000   rip = 0x00000000005779e0
    Found by: call frame info
 3  main.nexe!__cxa_throw [cxa_exception.cpp : 149 + 0x20]
    rbx = 0x00000000fd3d97d0   rbp = 0x00000000fffeff80
    rsp = 0x00000000fffe6e10   r12 = 0x00000000fd3c4738
    r13 = 0x00000000fffe6fa0   r14 = 0x00000000fd3d97b0
    r15 = 0x000006e700000000   rip = 0x0000000000577dc0
    Found by: call frame info
 4  main.nexe!InjectFaultCmd::DoFault(Cmd::Args const&) [vector : 312 + 0x20]
    rbx = 0x00000000fd3d97d0   rbp = 0x00000000fffeff80
    rsp = 0x00000000fffe6e30   r12 = 0x00000000fd3c4738
    r13 = 0x00000000fffe6fa0   r14 = 0x00000000fffe6fa0
    r15 = 0x000006e700000000   rip = 0x00000000001eb160
    Found by: call frame info
 5  main.nexe!InjectFaultCmd::Run(Cmd::Args const&) const [Command.cpp : 540 + 0x16]
    rbx = 0x0000000000000000   rbp = 0x00000000fffeff80
    rsp = 0x00000000fffe6e80   r12 = 0x00000000fd3c4738
    r13 = 0x00000000fffe6fa0   r14 = 0x00000000fd3c472c
    r15 = 0x000006e700000000   rip = 0x00000000001ea460
    Found by: call frame info
 6  main.nexe!Cmd::ExecuteSyscall(Util::Reader&, IPC::Channel&) [CommonProxies.cpp : 116 + 0x55]
    rbx = 0x0000000000000000   rbp = 0x00000000fffeff80
    rsp = 0x00000000fffe6ee0   r12 = 0x0000000000000000
    r13 = 0x0000000000000064   r14 = 0x0000000000000000
    r15 = 0x000006e700000000   rip = 0x00000000001ce580
    Found by: call frame info
 7  main.nexe!VM::VMHandleSyscall(unsigned int, Util::Reader) [CommonProxies.cpp : 138 + 0x20]
    rbx = 0x0000000000000000   rbp = 0x00000000fffeff80
    rsp = 0x00000000fffe6fe0   r12 = 0x00000000fffefed0
    r13 = 0x0000000000000064   r14 = 0x0000000000000000
    r15 = 0x000006e700000000   rip = 0x0000000000026b60
    Found by: call frame info
 8  main.nexe!main [VMMain.cpp : 71 + 0x20]
    rbx = 0x00000000fd3c4818   rbp = 0x00000000fffeff80
    rsp = 0x00000000fffefe90   r12 = 0x00000000fffefed0
    r13 = 0x0000000000000064   r14 = 0x00000000fffefeb0
    r15 = 0x000006e700000000   rip = 0x00000000001e7f60
    Found by: call frame info
 9  main.nexe!_start [start.c : 68 + 0x39]
    rbx = 0x0000000000000028   rbp = 0x00000000fffeff80
    rsp = 0x00000000fffeff40   r12 = 0x00000000fffeffbc
    r13 = 0x0000000000000002   r14 = 0x0000000000000028
    r15 = 0x000006e700000000   rip = 0x0000000000582d00
    Found by: call frame info

To do before merging:

  • Test native exe more
  • Make sure that if Log::Warn blows up it won't prevent us from getting a stack trace

slipher avatar Mar 16 '24 10:03 slipher

To do before merging:

* Test native exe more

* Make sure that if Log::Warn blows up it won't prevent us from getting a stack trace

Done.

slipher avatar Mar 19 '24 05:03 slipher

Bump

slipher avatar May 14 '24 20:05 slipher

I guess the segfault option is a variant of this?

Right. With incantations to stop the compilers from emitting a warning or optimizing it out.

slipher avatar May 14 '24 20:05 slipher