Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect execution flow divergence

Tags:

c++

debugging

gdb

I have an application that should produce the same output given the same input but it produces different outputs across executions.

Is it possible to use GDB to detect divergence between executions? Is it at all possible to automate this?

like image 242
perreal Avatar asked Feb 01 '26 18:02

perreal


1 Answers

Is it possible to use GDB to detect divergence between executions?

If the application is single-threaded, reverse debugging can help. See this article for an example using UndoDB.

You should also make sure there are no uninitialized memory reads, using either Valgrind or MemorySantizer.

If the application is multi-threaded, reverse debugging is unlikely to help, but data race detectors like ThreadSanitizer may.

Is it at all possible to automate this?

You can (and should) certainly run {Address,Memory,Thread}Sanitizer's regularly over your test suite (you do have a test suite, right?).

With reverse debugging, not much further automation should be necessary.

like image 169
Employed Russian Avatar answered Feb 04 '26 14:02

Employed Russian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!