-
-
Save XrXr/b3e2d57101248eaf286eed193ccbba54 to your computer and use it in GitHub Desktop.
A short reproducer for https://bugs.ruby-lang.org/issues/16682
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'tracepoint_crash' | |
RubyTracePointCrash.enable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mkmf' | |
$CFLAGS = "-Wall" | |
create_makefile('tracepoint_crash/tracepoint_crash') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To run, put all the files in this gist in a empty directory then run this script | |
ruby extconf.rb && make clean && make && ruby -v crasher.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ruby.h> | |
#include <ruby/debug.h> | |
static VALUE tracepoint = Qnil; | |
static void | |
gctracker_hook(VALUE tpval, void *data) | |
{ | |
fprintf(stderr, "hook is called\n"); | |
} | |
static VALUE | |
tracepoint_enable(VALUE klass) | |
{ | |
rb_event_flag_t events; | |
events = RUBY_INTERNAL_EVENT_GC_EXIT; | |
tracepoint = rb_tracepoint_new(Qnil, events, gctracker_hook, NULL); | |
rb_global_variable(&tracepoint); | |
rb_tracepoint_enable(tracepoint); | |
fprintf(stderr, "tp is %ld and it is now enabled\n", tracepoint); | |
return Qtrue; | |
} | |
void | |
Init_tracepoint_crash() | |
{ | |
VALUE cRubyTracePointCrash = rb_define_class("RubyTracePointCrash", rb_cObject); | |
rb_define_module_function(cRubyTracePointCrash, "enable", tracepoint_enable, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment