Skip to content

Instantly share code, notes, and snippets.

View k-tsj's full-sized avatar

Kazuki Tsujimoto k-tsj

View GitHub Profile
@k-tsj
k-tsj / gist:7854083
Created December 8, 2013 06:55
Extend rb_scan_args to get keyword arguments
diff --git a/array.c b/array.c
index 9a93d7f..b673c63 100644
--- a/array.c
+++ b/array.c
@@ -4429,7 +4429,7 @@ static VALUE sym_random;
static VALUE
rb_ary_shuffle_bang(int argc, VALUE *argv, VALUE ary)
{
- VALUE opts, randgen = rb_cRandom;
+ VALUE rnd, randgen = rb_cRandom;
@k-tsj
k-tsj / 0-report.txt
Created April 27, 2013 23:10
RGenGC(056c914e53c6) SEGV
$ make TESTS='--gc-stress objspace/test_objspace.rb pathname/test_pathname.rb' test-all
TestPathname#test_each_entry/home/kazuki/work/ruby/lib/pp.rb:165: [BUG] Segmentation fault
ruby 2.1.0dev (2013-04-25 trunk 40462) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0061 p:0008 s:0261 e:000259 METHOD /home/kazuki/work/ruby/lib/pp.rb:165
c:0060 p:0011 s:0255 e:000254 BLOCK /home/kazuki/work/ruby/lib/pp.rb:356
c:0059 p:0029 s:0252 e:000251 BLOCK /home/kazuki/work/ruby/lib/pp.rb:247 [FINISH]
c:0058 p:---- s:0249 e:000248 CFUNC :each
@k-tsj
k-tsj / gist:5180187
Last active December 15, 2015 01:29
ReplaceRepeated by Ruby
require 'pattern-match'
def replace_repeated(val, &block)
ret = match(val, &block)
if ret == val
ret
else
replace_repeated(ret, &block)
end
rescue PatternMatch::NoMatchingPatternError
@k-tsj
k-tsj / gist:4953202
Last active December 13, 2015 18:08
Bug #7825
diff --git a/vm.c b/vm.c
index 36def2c..89314c7 100644
--- a/vm.c
+++ b/vm.c
@@ -1782,7 +1782,14 @@ rb_thread_mark(void *ptr)
if (iseq) {
rb_gc_mark(RUBY_VM_NORMAL_ISEQ_P(iseq) ? iseq->self : (VALUE)iseq);
}
- if (cfp->me) ((rb_method_entry_t *)cfp->me)->mark = 1;
+ if (cfp->me) {
@k-tsj
k-tsj / gist:4754297
Last active December 12, 2015 09:49
Bug #7825 調査状況まとめ

r39197に対するパッチ。

diff —git a/vm.c b/vm.c index 36def2c..b646ea7 100644 - a/vm.c + b/vm.c @ -262,7 +262,7 @ ruby_vm_run_at_exit_hooks(rb_vm_t *vm) */ #define ENV_IN_HEAP_P(th, env) \
@k-tsj
k-tsj / gist:4527691
Created January 14, 2013 04:05
yamy-0.03-alt-tab.patch
diff --git a/hook.cpp b/hook.cpp
index 98b585d..b9a994f 100644
--- a/hook.cpp
+++ b/hook.cpp
@@ -810,6 +810,9 @@ static LRESULT CALLBACK lowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lP
if (g.m_keyboardDetour && g.m_engine) {
unsigned int result;
+ if (nCode == HC_ACTION && pKbll->vkCode == VK_TAB && pKbll->flags & LLKHF_ALTDOWN) {
+ goto through;
@k-tsj
k-tsj / gist:4303292
Last active July 22, 2018 06:59
CRuby ENABLE_TRAP patch
diff --git a/tool/ruby_vm/views/_insn_entry.erb b/tool/ruby_vm/views/_insn_entry.erb
index bae8eae890..08d16882ec 100644
--- a/tool/ruby_vm/views/_insn_entry.erb
+++ b/tool/ruby_vm/views/_insn_entry.erb
@@ -18,6 +18,11 @@ INSN_ENTRY(<%= insn.name %>)
% end
START_OF_ORIGINAL_INSN(<%= insn.name %>);
+if (rb_iseq_eval_main_p && getenv("ENABLE_TRAP")) {
+ rb_vmdebug_stack_dump_raw_current();
@k-tsj
k-tsj / gist:4249318
Created December 10, 2012 08:20
CRuby stack overflow detection

前提

  • Ubuntu 12.04 x64(pthread_attr_getstack利用可)
  • 図の上部側が下位アドレス
  • [stack]とあるのは/proc/[PID]/mapsで確認できる[stack]の先頭、末尾アドレス

pthread_attr_getstack由来の値

                                             +--------+ -----------------------------------

| 4KB | | |

Requirements

  • ruby 1.9.3-p0(–prefix=/usr/local/ruby-1.9.3)

  • gnuplot

Usage

cd /tmp
git clone git://github.com/ruby/ruby.git
cd ruby
cp -a benchmark /tmp
sh path/to/bm-run.sh
@k-tsj
k-tsj / gist:2601217
Created May 5, 2012 09:45
run boostraptest on mruby
2012-05-05 18:36:59 +0900
Driver is ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Target is ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
test_attr.rb syntax error, unexpected tLSHFT, expecting ')'
syntax error, unexpected '\n', expecting '{'
FF
test_autoload.rb FFFFFFFFFFFF.F
test_block.rb ..........FF...............F............FF.FFF.F.FFFFF.