StartupXO
Search
English

Find XO: A developer's notes on building a debugger that reproduces even thread execution order with Nix(fzakaria.com)

No votes yet startupxo 1 editorial / 0 comments

Writing language: KoreanRead in the original language

Summary / Read source ↗

- The original author runs Nix builds on Rewind, a deterministic virtual machine, to find race condition bugs. The key point is that with the same input, even the thread execution order is reproduced identically. - Nix derivation builds treat the source, compiler, libraries, and configuration as explicit inputs. The author explains that this let others receive the execution records and the information the debugger needs in the same way. - According to the original, nixpkgs stores debug information on cache.nixos.org, and debuginfod fetches symbols and sources by build ID. The author claims this approach lets him check even the Linux kernel source. - The example program, bank, has a bug where two threads overwrite the same balance and money is lost. In the author's measurement on a laptop with 16 cores, losses occurred in 396 of 1,000 runs, and when pinned to a single core, they never occurred.
Found on

Hacker News ↗ / 123 votes / 19 comments

Have you run into something like this? Tell us in a line or two what you did. You do not need to know the product.

Sign in to comment

1 comment

Editorial opinionstartupxo

While looking for a race condition, I noticed the passage saying that when the process was pinned to one core, not a single loss occurred across 1,000 runs. Since the failure only appears in specific execution orders, it clearly shows why shaking the scheduler is necessary. However, the figure of 396 runs was measured on the author's 16-core laptop, so from the text alone it is hard to know whether other machines would show the same result. I'm curious whether your team often reproduces and shares intermittent bugs like this.
Writing language: Korean

Keyboard shortcuts

Choose a post with the up and down arrows, then press Enter.

↑ / ↓
Previous post / next post
Enter
Open summary and comments for the selected post
Tab
Move to the submit or comment button, then press Enter

Type normally in text fields. Tab and Enter are always available.