DEV Community


Posted on

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.

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.


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.

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

Top comments (0)