5 ms·
There is a time-travelling debugger that forks the process at each statement, allowing you to go back to a previous statement and continue from that point.
by chrisseaton 8y ago
There is a time-travelling debugger that forks the process at each statement, allowing you to go back to a previous statement and continue from that point.
- dooglius 8y agoIt seems like forking so often would use up a system's resources very quickly. I'd imagine that each fork needs at least a handful of individual pages for OS bookkeeping overhead, so you'd get into the gigabyte range fast even with perfect copy-on-write.
- chrisseaton 8y agoYes you can't run like that forever. But you could break, step forward and backward and bit, and then resume. I often step forward while debugging, realise that whatever is going wrong has already gone wrong, and would like to step back a few steps.
- caf 8y agoIt's more than a handful of pages - each forked process requires its own set of page tables.
- adtac 8y agoVery interesting. Do you have a link where I can read more about this?
- CyberShadow 8y agoMozilla's rr (mentioned in the article) is a time-traveling debugger, but as far as I know it doesn't use fork() for snapshots / time-travel.
- roca 8y agorr does use fork() internally to create checkpoints, and checkpoints are created implicitly as the program executes to support time-travel. The COW behaviour of fork() is extremely helpful for performance. There's more to checkpoints than just fork(), though; for example, when two processes are sharing memory, checkpointing the process group fork()s both processes and then must explicitly duplicate the shared memory region, otherwise the checkpoint would share memory with the original, which would be disastrous. Unfortunately this means we don't get COW behaviour for shared memory regions; unfortunately the Linux/POSIX APIs are a bit deficient here.
- chrisseaton 8y agohttps://github.com/awwaiid/pry-timetravel https://github.com/awwaiid/pry-timetravel But I think the idea has been around forever.
- Pete_D 8y agogdb has checkpoint/restart that uses fork(), though you have to specify the checkpoints manually. https://sourceware.org/gdb/onlinedocs/gdb/Checkpoint_002fRestart.html https://sourceware.org/gdb/onlinedocs/gdb/Checkpoint_002fRes... It has another mode where you can record and rewind execution traces, which sounds more like the description, but I'm almost certain that doesn't use fork. https://sourceware.org/gdb/onlinedocs/gdb/Process-Record-and-Replay.html#Process-Record-and-Replay https://sourceware.org/gdb/onlinedocs/gdb/Process-Record-and...
- arcticbull 8y agoIt's cool but you can't un-write to disk, or un-send network packets making its applicability limited.
- tylerhou 8y ago> you can’t un-write to disk Why not? (Experimental) versioned file systems exist.
- arcticbull 8y agoI think the broader point I'm making is that these time traveling debuggers can't work in the general case due to externalities.