beehive-lab / mambo

A low-overhead dynamic binary instrumentation and modification tool for ARM (both AArch32 and AArch64 support) and RISC-V (RV64GC).
Apache License 2.0
320 stars 69 forks source link

Add data race detector plugin #130

Closed AlphaDaze closed 2 months ago

AlphaDaze commented 2 months ago

This PR adds a data race detector plugin. This plugin detects possible data races within the underlying program along with information that can be utilised for debugging.

The README provides further context for the plugin and its usage.

Compile with make datarace_ft and run with mambo_datarace_ft. The plugin includes two algorithms which can be compiled separately: fasttrack and djit. Both are happens-before algorithms with fasttrack being an improvement over djit with both memory and runtime.

All comments and suggestions are welcome!

Sample output

--- FORK: Thread 1029188 created by 0
--- LOCK: Thread 1029188 locked 0x7fff22128b10
--- UNLOCK: Thread 1029188 unlocked 0x7fff22128b10
--- FORK: Thread 1029189 created by 1029188
--- LOCK: Thread 1029188 locked 0x7fff22128b10
--- UNLOCK: Thread 1029188 unlocked 0x7fff22128b10
--- FORK: Thread 1029223 created by 1029188
--- JOIN: Thread 1029189 joining 1029188
!!! READ RACE: Possible read race - 0x41104c by thread 1029223
>>>> at 0x40074c: /home/user/Documents/git/tests/hg04_race (0x400744) (th10)
!!! WRITE RACE: Possible write race - 0x41104c by thread 1029223
>>>> at 0x40075c: /home/user/Documents/git/tests/hg04_race (0x400744) (th10)
--- JOIN: Thread 1029223 joining 1029188
--- LOCK: Thread 1029188 locked 0x7fff22128ab0
--- UNLOCK: Thread 1029188 unlocked 0x7fff22128ab0
We're done; exiting with status: 0
AlphaDaze commented 2 months ago

Sounds good! Thanks for taking a look at it. I have rebased and squashed the relevant commits together as requested.

If there is any other changes (however small), please do let me know.

josh-nook commented 2 months ago

Looks good to me (I'm a new intern). The markdown reads well

IgWod commented 2 months ago

Looks good to me! I'll ask @jkressel to have a look now.