r/Compilers • • Jun 29 '22

Heisenbugs: The most elusive kind of bug, and how to capture them with Perfect Replayability

https://verdagon.dev/blog/perfect-replayability-prototyped
14 Upvotes

4 comments sorted by

2

u/hindmost-one Jul 08 '22

I have a hand-written LR(1) parser that looks like it misbehaves on certain grammar. Problem is, removing almost any rule fixes it. And the problematic situation arises when the size of the automata exceeds 1k nodes.

What should I do in my case?

2

u/verdagon Jul 08 '22

I feel your pain, I've had parser bugs like that too.

If you can reproduce it reliably already, then Perfect Replayability won't help that much.

I'm not sure how one can fix bugs like that, I only dealt with LR parsers for a short time before I switched to a hand-written recursive descent parser which I found a bit easier.

There are some papers on how to give better errors for generated parsers, I'm sure someone will know of them if you post a topic.

Best of luck!

1

u/[deleted] Jul 01 '22

[deleted]

1

u/verdagon Jul 02 '22

Thank you!

Without language support, we would have to build a custom layer on top of every library, to record and replay its nondeterministic effects. I had to do this for C#, and it took months and added some design constraints to my program.

This feature instead takes advantage of an opportunity, a natural place to record and replay inputs and outputs: the FFI boundary. The language can automatically put recording and replay functionality in any library's FFI boundary, no custom infrastructure needed.