SlideShare a Scribd company logo
1 of 53
Download to read offline
For each universe 
there are a dozen others; 
one must lack my bug?
A Partial-Multiverse Model 
of Time Travel 
for Debugging 
RubyConf 2014 
Brock Wilcox 
awwaiid@thelackthereof.org 
bwilcox@optoro.com
awwaiid@rbconf:~$ whoami
Debuggers
pry-byebug
How does THAT work‽
Sweet
OK. What could be better?
MAD SCIENCE
pry-timetravel
And we're done!
The Idea 
(nothing new under the sun)
fork() the universe during 'next'
Suspend the child fork
Keep track of all created child forks
Upon 'back', grab the most recent child fork
Resume (time-travel!) the previous child fork
Wha?
Two essential ingredients.
Unix fork()
New child process: 
new (child) PID 
copy of memory 
share file handles (sockets) 
... other stuff 
runs separately
Copy-On-Write!
Signals
Registered OS callbacks
SIGINT 
SIGTERM 
SIGKILL 
SIGHUP 
SIGUSR1 
SIGALRM 
SIGTSTP
SIGINT (^C) 
SIGTERM (kill) 
SIGKILL (kill -9) 
SIGHUP (daemon reload) 
SIGUSR1 (... things ...) 
SIGALRM (just another 5 minutes!)
Signal handling / sending in Ruby
SIGTSTP (^Z) 
SIGSTOP 
SIGCONT
def snap 
if child_pid = fork 
# I am the parent! 
Process.kill 'SIGSTOP', $$ 
else 
# I am the child! 
@snap_pid.push child_pid 
end 
end
def restore 
Process.kill 'SIGCONT', @snap_pid[-1] 
Process.kill 'SIGSTOP', $$ 
end
Limitation: 
Shared file handles (inc. sockets!)
Limitation: 
External state.
Limitation: 
Threads. Not so much.
Limitation: 
Can only travel back to checkpoints 
(see also: Primer)
Limitation: 
Might crash the multiverse through 
memory exhaustion. I guess.
Wrap in a pry plugin 
and we're done, right?
Complication: 
Shell detects STOP
awwaiid@floyd:~$ pry 
[1] pry(main)> 
zsh: suspended (signal) pry
Fix: 
Make a dummy parent process 
that just sleeps (or sig-pause)
Complication: 
Killing parent snapshots
Fix: 
Let the One True (parent) snapshot 
kill all of its children (via SIGUSR1). 
(also: nope. totally wrong.)
Complication: 
Every snapshot wants to clean up
Fix: 
If you are not the current snapshot, 
terminate yourself without cleanup!
Complication: 
ZOMBIES
Zombie: 
Child process that has exited nicely 
but then the parent exited not-nicely. 
The process is dead, yet remains.
Great. Now we can go back!
I WANT MOAR
Tree of snapshots
TODO: auto-snapshot
References: 
https://github.com/TomOnTime/timetravelpdb 
http://programmers.stackexchange.com 
/questions/181527 
/why-is-reverse-debugging-rarely-used 
http://debug.elm-lang.org/
If I had the chance 
I'd write a better haiku 
oh wait, I HAVE A TIME MACHINE
THE END

More Related Content

What's hot

Debugging Rails 3 Applications
Debugging Rails 3 ApplicationsDebugging Rails 3 Applications
Debugging Rails 3 Applications
Nathan Broadbent
 

What's hot (12)

Docker and plone
Docker and ploneDocker and plone
Docker and plone
 
Chef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & ChefChef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & Chef
 
Proces
ProcesProces
Proces
 
Debugging Rails 3 Applications
Debugging Rails 3 ApplicationsDebugging Rails 3 Applications
Debugging Rails 3 Applications
 
What Zope Did Wrong (PyCon 2008)
What Zope Did Wrong (PyCon 2008)What Zope Did Wrong (PyCon 2008)
What Zope Did Wrong (PyCon 2008)
 
Bb health ai_jan26_v2
Bb health ai_jan26_v2Bb health ai_jan26_v2
Bb health ai_jan26_v2
 
Coroutines talk ppt
Coroutines talk pptCoroutines talk ppt
Coroutines talk ppt
 
Django Toolbox
Django ToolboxDjango Toolbox
Django Toolbox
 
Containers from Scratch: what are they made from?
Containers from Scratch: what are they made from?Containers from Scratch: what are they made from?
Containers from Scratch: what are they made from?
 
Into The Box 2018 Automate Your Test
Into The Box 2018 Automate Your Test Into The Box 2018 Automate Your Test
Into The Box 2018 Automate Your Test
 
JDK, the not so hidden treasures
JDK, the not so hidden treasuresJDK, the not so hidden treasures
JDK, the not so hidden treasures
 
Koha Cronjobs
Koha CronjobsKoha Cronjobs
Koha Cronjobs
 

Similar to A Partial Multiverse Model of Time Travel for Debugging

exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
tutorialsruby
 
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
tutorialsruby
 

Similar to A Partial Multiverse Model of Time Travel for Debugging (20)

Bugs from Outer Space | while42 SF #6
Bugs from Outer Space | while42 SF #6Bugs from Outer Space | while42 SF #6
Bugs from Outer Space | while42 SF #6
 
Spaceship At £5 App
Spaceship At £5 AppSpaceship At £5 App
Spaceship At £5 App
 
Ipc
IpcIpc
Ipc
 
Boxen: How to Manage an Army of Laptops
Boxen: How to Manage an Army of LaptopsBoxen: How to Manage an Army of Laptops
Boxen: How to Manage an Army of Laptops
 
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis
 
[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation
 
NYAN Conference: Debugging asynchronous scenarios in .net
NYAN Conference: Debugging asynchronous scenarios in .netNYAN Conference: Debugging asynchronous scenarios in .net
NYAN Conference: Debugging asynchronous scenarios in .net
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
Killer Bugs From Outer Space
Killer Bugs From Outer SpaceKiller Bugs From Outer Space
Killer Bugs From Outer Space
 
Puppet@Citygrid - Julien Rottenberg - PuppetCamp LA '12
Puppet@Citygrid - Julien Rottenberg - PuppetCamp LA '12Puppet@Citygrid - Julien Rottenberg - PuppetCamp LA '12
Puppet@Citygrid - Julien Rottenberg - PuppetCamp LA '12
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
 
Open shift
Open shiftOpen shift
Open shift
 
Infrastructure as code might be literally impossible
Infrastructure as code might be literally impossibleInfrastructure as code might be literally impossible
Infrastructure as code might be literally impossible
 
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
 
Macruby intro
Macruby introMacruby intro
Macruby intro
 
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
 
Advanced debugging  techniques in different environments
Advanced debugging  techniques in different environmentsAdvanced debugging  techniques in different environments
Advanced debugging  techniques in different environments
 
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
 
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
 
Puppet Camp Berlin 2015: Rapid testing Setups for Puppet
Puppet Camp Berlin 2015: Rapid testing Setups for PuppetPuppet Camp Berlin 2015: Rapid testing Setups for Puppet
Puppet Camp Berlin 2015: Rapid testing Setups for Puppet
 

More from awwaiid (8)

2015-10-07 PPDC HTTP Adapters
2015-10-07 PPDC HTTP Adapters2015-10-07 PPDC HTTP Adapters
2015-10-07 PPDC HTTP Adapters
 
2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rb2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rb
 
Random. Kinda.
Random. Kinda.Random. Kinda.
Random. Kinda.
 
Mad Science: Polyglot Bridges
Mad Science: Polyglot BridgesMad Science: Polyglot Bridges
Mad Science: Polyglot Bridges
 
Rakudo
RakudoRakudo
Rakudo
 
RailsGirls DC 2012 - Debugging
RailsGirls DC 2012 - DebuggingRailsGirls DC 2012 - Debugging
RailsGirls DC 2012 - Debugging
 
NoiseGen at Arlington Ruby 2012
NoiseGen at Arlington Ruby 2012NoiseGen at Arlington Ruby 2012
NoiseGen at Arlington Ruby 2012
 
PPW2007 - Continuity Project
PPW2007 - Continuity ProjectPPW2007 - Continuity Project
PPW2007 - Continuity Project
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

A Partial Multiverse Model of Time Travel for Debugging