# Patch for

**URL:** <https://www.ruby-forum.com/t/patch-for/134576>\
**Category:** Development\
**Created:** [April 12, 2008, 8:23am UTC](https://www.ruby-forum.com/t/patch-for/134576 "2008-04-12T08:23:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wanabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@wanabe](https://www.ruby-forum.com/u/wanabe)\
**Post date:** [April 12, 2008, 8:23am UTC](https://www.ruby-forum.com/t/patch-for/134576/1 "2008-04-12T08:23:31Z")

</div>

e$B%o%J%Y$H?=$7$^$9!#e(B

Fiber e$B$N%H%C%W%U%l!\<%`$Ke(B ISeq e$B$r2C$($k%Q%C%A$r=q$-$^$7$?!#e(B  
e$B$D$$$G$J$N$Ge(B Thread e$B$bF1MM$K$7$^$7$?!#e(B  
test\_knownbug.rb e$B$Ne(B [ruby-dev:34128]  
e$B$H$"$k%F%9%H$,DL$k$h$&$K$J$j$^$9!#e(B

e$B%P%C%/%H%l!\<%9BP:v$Ge(B iseq-\>filename e$B$Ke(B nil  
e$B$rF~$l$F$7$^$$$^$7$?$,e(B  
e$B!JIaDL$Ke(B filename  
e$B$rF~$l$k$H!"e(BFiber.new(method(:load)).resume e$B$Ge(B  
e$B!!%U%!%$%kL\>$,6uJ8;zNs!"9THV9f$,e(B 0 e$B$J$I$HI=\<($5$l$k!Ke(B  
e$BK\Mh$O$I$&BP=h$9$k$N$,%9%^!\<%H$J$N$G$7$g$&$+!#e(B

# Index: eval\_error.c

— eval\_error.c (revision 15933)  
+++ eval\_error.c (working copy)  
@@ -10,11 +10,11 @@  
rb\_control\_frame\_t \*cfp = vm\_get\_ruby\_level\_cfp(th, th-\>cfp);

```
 if (cfp) {

```

- return RSTRING\_PTR(cfp-\>iseq-\>filename);

- if (!NIL\_P(cfp-\>iseq-\>filename)) {
- 

```
 return RSTRING_PTR(cfp->iseq->filename);

```

- }  
}

- else {
- return 0;
- }

- return 0;  
}

# int Index: cont.c

— cont.c (revision 15933)  
+++ cont.c (working copy)  
@@ -501,6 +501,8 @@  
rb\_context\_t \*cont = fiber\_alloc(klass);  
VALUE contval = cont-\>self;  
rb\_thread\_t \*th = &cont-\>saved\_thread;

- VALUE filename = rb\_str\_new2("");

- VALUE iseq = rb\_iseq\_new(0, filename, Qnil, 0, ISEQ\_TYPE\_TOP);

- th-\>cfp = (void \*)(th-\>stack + th-\>stack\_size);
- th-\>cfp–;
- th-\>cfp-\>pc = 0;
- th-\>cfp-\>sp = th-\>stack + 1;
- th-\>cfp-\>bp = 0;
- th-\>cfp-\>lfp = th-\>stack;
- \*th-\>cfp-\>lfp = 0;
- th-\>cfp-\>dfp = th-\>stack;
- th-\>cfp-\>self = Qnil;
- th-\>cfp-\>flag = 0;
- th-\>cfp-\>iseq = 0;
- th-\>cfp-\>proc = 0;

- vm\_set\_branch\_frame(th, iseq);  
th-\>cfp-\>block\_iseq = 0;  
th-\>tag = 0;  
th-\>local\_storage = st\_init\_numtable();  
Index: vm.c  
===================================================================  
— vm.c (revision 15933)  
+++ vm.c (working copy)  
@@ -1666,6 +1666,17 @@  
return obj;  
}

+void  
+vm\_set\_branch\_frame(rb\_thread\_t \*th, VALUE iseqval)  
+{

- rb\_iseq\_t \*iseq;
- 
- th-\>cfp = (void \*)(th-\>stack + th-\>stack\_size);
- GetISeqPtr(iseqval, iseq);
- vm\_push\_frame(th, iseq, FRAME\_MAGIC\_TOP, th-\>top\_self, 0,
- 

```
 iseq->iseq_encoded, th->stack, 0, iseq->local_size);

```

+}  
+  
static void  
th\_init2(rb\_thread\_t \*th)  
{  
@@ -1687,24 +1698,37 @@  
}

static void  
-th\_init(rb\_thread\_t \*th)  
+th\_init(rb\_thread\_t \*th, VALUE iseq)  
{

- th\_init2(th);

- /\* allocate thread stack \*/
- th-\>stack\_size = RUBY\_VM\_THREAD\_STACK\_SIZE;
- th-\>stack = thread\_recycle\_stack(th-\>stack\_size);
- 
- vm\_set\_branch\_frame(th, iseq);
- 
- th-\>status = THREAD\_RUNNABLE;
- th-\>errinfo = Qnil;
- 

+#if USE\_VALUE\_CACHE

- th-\>value\_cache\_ptr = &th-\>value\_cache[0];  
+#endif  
}

static VALUE  
ruby\_thread\_init(VALUE self)  
{

- VALUE filename = rb\_str\_new2("");
- VALUE iseq = rb\_iseq\_new(0, filename, Qnil, 0, ISEQ\_TYPE\_TOP);  
rb\_thread\_t \*th;  
rb\_vm\_t \*vm = GET\_THREAD()-\>vm;  
GetThreadPtr(self, th);

- th\_init(th);  
th-\>self = self;  
th-\>vm = vm;

- th\_init(th, iseq);  
return self;  
}

# Index: vm\_dump.c

— vm\_dump.c (revision 15933)  
+++ vm\_dump.c (working copy)  
@@ -102,7 +102,12 @@  
line = vm\_get\_sourceline(cfp);  
if (line) {  
char fn[MAX\_POSBUF+1];

- snprintf(fn, MAX\_POSBUF, “%s”, RSTRING\_PTR(cfp-\>iseq-\>filename));

- VALUE filename = cfp-\>iseq-\>filename;
- 
- if (NIL\_P(filename)) {
- 

```
   filename = cfp->iseq->name;

```

- }
- snprintf(fn, MAX\_POSBUF, “%s”, RSTRING\_PTR(filename));  
snprintf(posbuf, MAX\_POSBUF, “%s:%d”, fn, line);  
}  
}

---

<div class="post-metadata">

**Author:** ![wanabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@wanabe](https://www.ruby-forum.com/u/wanabe)\
**Post date:** [April 12, 2008, 8:32am UTC](https://www.ruby-forum.com/t/patch-for/134576/2 "2008-04-12T08:32:52Z")

</div>

e$B%o%J%Y$G$9!#e(B

e$B$9$_$^$;$s!"BjL\>$r%_%9$7$^$7$?!#e(B  
e$BFbMF$+$i$o$+$k$H;W$$$^$9$,!"e(Bpatch for [ruby-dev:34128]e$B$G$9!#e(B

---

<div class="post-metadata">

**Author:** ![wanabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@wanabe](https://www.ruby-forum.com/u/wanabe)\
**Post date:** [April 12, 2008, 4:49pm UTC](https://www.ruby-forum.com/t/patch-for/134576/3 "2008-04-12T16:49:45Z")

</div>

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34353] Re: patch for”  
on Sat, 12 Apr 2008 15:32:09 +0900, wanabe [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
writes:

|e$B$9$_$^$;$s!"BjL\>$r%_%9$7$^$7$?!#e(B  
|e$BFbMF$+$i$o$+$k$H;W$$$^$9$,!"e(Bpatch for [ruby-dev:34128]e$B$G$9!#e(B

e$B%o%J%Y$5$s$,%\_%9$7$?$N$G$O$J$/!"%j%9%H%5!\<%P$,e(BSubjecte$B$+$i%?%0e(B  
e$B$r\>C5n$9$k=hM}$K0z$C$+$+$C$A$c$C$?$N$@$H;W$$$^$9!#e(B

---

<div class="post-metadata">

**Author:** ![wanabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@wanabe](https://www.ruby-forum.com/u/wanabe)\
**Post date:** [April 14, 2008, 1:46am UTC](https://www.ruby-forum.com/t/patch-for/134576/4 "2008-04-14T01:46:19Z")

</div>

e$B!!$5$5$@$G$9!%e(B

e$B!!H?1~$,CY$/$F$9$\_$^$;$s!%e(B

wanabe wrote:

> Fiber e$B$N%H%C%W%U%l!\<%`$Ke(B ISeq e$B$r2C$($k%Q%C%A$r=q$-$^$7$?!#e(B  
> e$B$D$$$G$J$N$Ge(B Thread e$B$bF1MM$K$7$^$7$?!#e(B  
> test\_knownbug.rb e$B$Ne(B [ruby-dev:34128] e$B$H$"$k%F%9%H$,DL$k$h$&$K$J$j$^$9!#e(B

e$B!!%@%_!\<$rF~$l$F$k$H;W$&$s$G$9$,!$Kh2sI,MW$J$b$s$G$7$g$&$+!%$"$s$^$je(B  
e$BLdBj$H2r7h$rM}2r$7$F$$$^$;$s!$$9$_$^$;$s!%e(B

> e$B%P%C%/%H%l!\<%9BP:v$Ge(B iseq-\>filename e$B$Ke(B nil e$B$rF~$l$F$7$^$$$^$7$?$,e(B  
> e$B!JIaDL$Ke(B filename e$B$rF~$l$k$H!"e(BFiber.new(method(:load)).resume e$B$Ge(B  
> e$B!!%U%!%$%kL\>$,6uJ8;zNs!"9THV9f$,e(B 0 e$B$J$I$HI=\<($5$l$k!Ke(B  
> e$BK\Mh$O$I$&BP=h$9$k$N$,%9%^!\<%H$J$N$G$7$g$&$+!#e(B

e$B!!%U%!%$%kL\>$rF~$l$?$N$K!V%U%!%$%kL\>$,6uJ8;zNs!"9THV9f$,e(B  
0e$B!W$G$9$+!)e(B  
e$B!!$d$C$F$\_$J$$$H$o$+$i$J$$$J!%e(B

e$B!!e(Bvm\_set\_branch\_frame(rb\_thread\_t \*th, VALUE iseqval)  
e$B$NL\>A0$O5$$K$Je(B  
e$B$j$^$7$?!%e(B

e$B!!$"$H!$e(Bth\_init() e$B$O%3%T!\<$G$9$+!%e(B

e$B!!$b$75$$K$5$l$J$1$l$P!$$3$l$r;29M$K;d$NJ}$GBP1~$7$?$$$H;W$&$N$G$9e(B  
e$B$,!$$h$m$7$$$G$7$g$&$+!%e(B

---

<div class="post-metadata">

**Author:** ![wanabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@wanabe](https://www.ruby-forum.com/u/wanabe)\
**Post date:** [April 14, 2008, 1:29am UTC](https://www.ruby-forum.com/t/patch-for/134576/5 "2008-04-14T01:29:57Z")

</div>

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34352] patch for”  
on Sat, 12 Apr 2008 15:22:54 +0900, wanabe [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
writes:

|Fiber e$B$N%H%C%W%U%l!\<%`$Ke(B ISeq e$B$r2C$($k%Q%C%A$r=q$-$^$7$?!#e(B  
|e$B$D$$$G$J$N$Ge(B Thread e$B$bF1MM$K$7$^$7$?!#e(B  
|test\_knownbug.rb e$B$Ne(B [ruby-dev:34128] e$B$H$"$k%F%9%H$,DL$k$h$&$K$J$j$^$9!#e(B

e$B$3$l!“\<h$j9~$\_$?$$$s$G$9$,!”$5$5$@$/$s$N%A%'%C%/$rBT$C$?J}$,e(B  
e$B$h$$$N$+$7$i!)e(B

---

<div class="post-metadata">

**Author:** ![wanabe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@wanabe](https://www.ruby-forum.com/u/wanabe)\
**Post date:** [April 16, 2008, 1:41pm UTC](https://www.ruby-forum.com/t/patch-for/134576/6 "2008-04-16T13:41:11Z")

</div>

e$B%o%J%Y$G$9!#e(B

08/04/14 e$B$Ke(B SASADA Koichi[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) e$B$5$s$O=q$-$^$7$?e(B:

> > Fiber e$B$N%H%C%W%U%l!\<%`$Ke(B ISeq e$B$r2C$($k%Q%C%A$r=q$-$^$7$?!#e(B  
> > e$B!JCfN,!Ke(B  
> > e$B!!%@%_!\<$rF~$l$F$k$H;W$&$s$G$9$,!$Kh2sI,MW$J$b$s$G$7$g$&$+!%$"$s$^$je(B  
> > e$BLdBj$H2r7h$rM}2r$7$F$$$^$;$s!$$9$_$^$;$s!%e(B

e$B3N$+e(B vm\_get\_ruby\_level\_cfp()  
e$B$,;\_$^$C$F$/$l$:$Ke(B0e$B$rJV$9;v$,LdBj$@$C$?5$$,$7$^$9!#e(B  
[ruby-dev:34128]e$B!!$K$h$l$Pe(B “abc”.enum\_for(:scan, /./).next  
e$B$,Mn$A$kBeI=Nc$N$h$&$G$9!#e(B

> vm\_set\_branch\_frame(rb\_thread\_t \*th, VALUE iseqval) e$B$NL\>A0$O5$$K$Je(B  
> e$B$j$^$7$?!%e(B

e$B\<+J,$G$b$=$&;W$$$^$9!#;W$$$D$+$J$+$C$?$N$GE,Ev$K$D$1$^$7$?!#e(B

> e$B$"$H!$e(Bth\_init() e$B$O%3%T!\<$G$9$+!%e(B

e$B$=$&$G$9!#e(B

> e$B$b$75$$K$5$l$J$1$l$P!$$3$l$r;29M$K;d$NJ}$GBP1~$7$?$$$H;W$&$N$G$9e(B  
> e$B$,!$$h$m$7$$$G$7$g$&$+!%e(B

e$B$\<$R$_4j$$$7$^$9!#e(B  
e$BAw$C$?%Q%C%A$O$H$j$"$($:F0$/$@$1$NBeJ_$G$9$N$G!#e(B
