Debugging a Crash in Unsafe Rust with Windbg

rustdesk

RustDesk

Posted on June 3, 2021

Debugging a Crash in Unsafe Rust with Windbg

Lately, I had a crash in my Rust project on Windows. It is hard to get any clue from the console messages, because it is a segmentfault crash related to unsafe rust code.

error: process didn't exit successfully: `target\debug\rustdesk.exe` (exit code: 0xc0000374, STATUS_HEAP_CORRUPTION)
Enter fullscreen mode Exit fullscreen mode

I am familiar with Linux debugging tools like GDB and Valgrind. So I attempted to use Windbg.

Install Windbg

Download and install Windbg via below link first.
https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-download-tools

Debug with Windbg

Start your program cargo run. It is ok to run release version, but debug version has a bit of nicer symbol information.

Open Windbg, and attach your process as below.

image

Then the process is attached and paused. Please click on "Go" button on Windbg toolbar to continue the process.

Now you can run your program until it crashes, and get a crash stack in Windbg as below.
image

This is not the exact location that caused the crash,but it does help me solve the problem.

💖 💪 🙅 🚩
rustdesk
RustDesk

Posted on June 3, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related