Skip to content

Instantly share code, notes, and snippets.

@dparnell
Last active August 29, 2015 14:04
Show Gist options
  • Save dparnell/dde5f9ae5345634f0a9e to your computer and use it in GitHub Desktop.
Save dparnell/dde5f9ae5345634f0a9e to your computer and use it in GitHub Desktop.
Crash V8 if you leave it running long enough
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'v8'
require 'time'
module Crash
module Triggers
class Console
def info(msg)
Crash::Triggers.add_action({ :action => :log, :level => :info, :value => msg })
print "\r[JSTrigger] [\033[32mINFO \033[m] #{msg} "
end
end
class JSRoot
def console
@console ||= Console.new
end
end
def self.reset
@actions = []
end
def self.add_action(a)
reset if @actions.nil?
@actions << a
end
def self.actions
@actions
end
def self.test
if @context.nil?
puts "Creating new v8 context"
@context = V8::Context.new({ :with => JSRoot.new })
end
Crash::Triggers.reset
@context.eval "console.info('#{Time.now.inspect}')"
end
end
end
puts "Starting test at #{Time.now.inspect}"
while true
Crash::Triggers.test
end
gem 'therubyracer'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment