[#13842] Better introspection for Frames, Thread, and enhancing binding. — "Rocky Bernstein" <rocky.bernstein@...>

The below is a little long. So here's a summary.

11 messages 2007/12/01

[#13851] Array#flatten works quadratic time on length of resulting array. It could be linear — "Voroztsov Artem" <artem.voroztsov@...>

I encountered problem with Array#flatten slowness (it can be much

19 messages 2007/12/03
[#13863] Re: Array#flatten works quadratic time on length of resulting array. It could be linear — Charles Oliver Nutter <charles.nutter@...> 2007/12/03

Voroztsov Artem wrote:

[#13867] Re: Array#flatten works quadratic time on length of resulting array. It could be linear — "Voroztsov Artem" <artem.voroztsov@...> 2007/12/03

2007/12/3, Charles Oliver Nutter <charles.nutter@sun.com>:

[#13868] Re: Array#flatten works quadratic time on length of resulting array. It could be linear — "Voroztsov Artem" <artem.voroztsov@...> 2007/12/03

2007/12/3, Voroztsov Artem <artem.voroztsov@gmail.com>:

[#13870] Re: Array#flatten works quadratic time on length of resulting array. It could be linear — "Yusuke ENDOH" <mame@...> 2007/12/03

Hi,

[#13903] Clarification of retry change — Charles Oliver Nutter <charles.nutter@...>

Matz confirmed that retry-outside-rescue will no longer work, but I

14 messages 2007/12/07
[#13905] Re: Clarification of retry change — SASADA Koichi <ko1@...> 2007/12/07

Hi,

[#13908] What's the status of compiler/compiling on windows? — Gonzalo Garramu <ggarra@...>

20 messages 2007/12/07
[#13913] Re: What's the status of compiler/compiling on windows? — Nobuyoshi Nakada <nobu@...> 2007/12/07

Hi,

[#13914] Re: [Spam] Re: What's the status of compiler/compiling on windows? — Gonzalo Garramu <ggarra@...> 2007/12/07

Nobuyoshi Nakada wrote:

[#13926] Re: [Spam] Re: What's the status of compiler/compiling on windows? — "Luis Lavena" <luislavena@...> 2007/12/07

T24gRGVjIDcsIDIwMDcgODoyMSBBTSwgR29uemFsbyBHYXJyYW11w7FvIDxnZ2FycmFAYWR2YW5j

[#14038] Re: [Spam] Re: What's the status of compiler/compiling on windows? — "Joe Swatosh" <joe.swatosh@...> 2007/12/12

Hi Luis

[#14039] Re: [Spam] Re: What's the status of compiler/compiling on windows? — "Luis Lavena" <luislavena@...> 2007/12/12

On Dec 12, 2007 4:05 PM, Joe Swatosh <joe.swatosh@gmail.com> wrote:

[#14040] Re: [Spam] Re: What's the status of compiler/compiling on windows? — "Austin Ziegler" <halostatue@...> 2007/12/12

> This was discussed in other thread in ruby-talk, but just to summarize:

[#13969] redefineable not operator — David Flanagan <david@...>

Matz,

37 messages 2007/12/10
[#13971] Re: redefineable not operator — murphy <murphy@...> 2007/12/10

David Flanagan wrote:

[#13972] Re: redefineable not operator — Yukihiro Matsumoto <matz@...> 2007/12/10

Hi,

[#14007] Re: redefineable not operator — murphy <murphy@...> 2007/12/11

Yukihiro Matsumoto wrote:

[#14011] Re: redefineable not operator — Yukihiro Matsumoto <matz@...> 2007/12/11

Hi,

[#14013] Re: redefineable not operator — murphy <murphy@...> 2007/12/12

Yukihiro Matsumoto wrote:

[#14016] Re: redefineable not operator — David Flanagan <david@...> 2007/12/12

murphy wrote:

[#14019] Re: redefineable not operator — Yukihiro Matsumoto <matz@...> 2007/12/12

Hi,

[#14024] Re: redefineable not operator — Gary Wright <gwtmp01@...> 2007/12/12

[#14029] Re: redefineable not operator — Dave Thomas <dave@...> 2007/12/12

[#14042] Fix e2mmap.rb for 1.9 — Eric Hodel <drbrain@...7.net>

E2MM.Raise complains about $! being read-only now, and E2MM is used by

22 messages 2007/12/13
[#14043] Re: Fix e2mmap.rb for 1.9 — Dave Thomas <dave@...> 2007/12/13

[#14049] RDoc + irb (Was: Fix e2mmap.rb for 1.9) — Eric Hodel <drbrain@...7.net> 2007/12/13

On Dec 12, 2007, at 16:19 PM, Dave Thomas wrote:

[#14052] Re: RDoc + irb (Was: Fix e2mmap.rb for 1.9) — Dave Thomas <dave@...> 2007/12/13

[#14056] Re: RDoc + irb (Was: Fix e2mmap.rb for 1.9) — Charles Oliver Nutter <charles.nutter@...> 2007/12/13

Dave Thomas wrote:

[#14123] Some Ruby 1.9 loose ends to tie up — David Flanagan <david@...>

Matz,

20 messages 2007/12/17
[#14220] Re: Some Ruby 1.9 loose ends to tie up — Yukihiro Matsumoto <matz@...> 2007/12/21

Hi,

[#14238] Re: Some Ruby 1.9 loose ends to tie up — Charles Oliver Nutter <charles.nutter@...> 2007/12/22

Yukihiro Matsumoto wrote:

[#14147] named captures assigning to local variables — David Flanagan <david@...>

I've just been browsing ruby-dev. For an english speaker, it is kind of

26 messages 2007/12/19
[#14150] Re: named captures assigning to local variables — Tanaka Akira <akr@...> 2007/12/19

In article <47686B87.7050609@davidflanagan.com>,

[#14158] Re: named captures assigning to local variables — david@... 2007/12/19

Thank you for the clarification, akr. I'm embarassed to say that it didn't

[#14161] Re: named captures assigning to local variables — David Flanagan <david@...> 2007/12/20

If I may, have a proposal. My apologies if this has already been

[#14170] Re: named captures assigning to local variables — Tanaka Akira <akr@...> 2007/12/20

In article <476A087E.3070000@davidflanagan.com>,

[#14172] Re: named captures assigning to local variables — David Flanagan <david@...> 2007/12/20

How about making the return value an array of the captured strings, or nil

[#14149] Experimental PATCH to improve thread performance — Brent Roman <brent@...>

The attached patch against Ruby 1.8.6-p110 improves the performance of

38 messages 2007/12/19
[#14202] Re: Experimental PATCH to improve thread performance — Charles Oliver Nutter <charles.nutter@...> 2007/12/21

Brent Roman wrote:

[#14257] Re: Experimental PATCH to improve thread performance — Brent Roman <brent@...> 2007/12/22

[#14266] Re: Experimental PATCH to improve thread performance — Charles Oliver Nutter <charles.nutter@...> 2007/12/22

Brent Roman wrote:

[#14274] Re: Experimental PATCH to improve thread performance — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2007/12/22

On Sat, Dec 22, 2007 at 11:07:25PM +0900, Charles Oliver Nutter wrote:

[#14186] Rake 0.8.0 added to Ruby — Jim Weirich <jim.weirich@...>

Just a heads up here. I've added Rake (version 0.8.0 ... the latest)

34 messages 2007/12/21
[#14210] Re: [Spam] Rake 0.8.0 added to Ruby — Gonzalo Garramu <ggarra@...> 2007/12/21

Jim Weirich wrote:

[#14213] Re: [Spam] Rake 0.8.0 added to Ruby — "Rick DeNatale" <rick.denatale@...> 2007/12/21

On Dec 21, 2007 10:24 AM, Gonzalo Garramu=F1o <ggarra@advancedsl.com.ar> wr=

[#14215] Re: [Spam] Rake 0.8.0 added to Ruby — Jim Weirich <jim.weirich@...> 2007/12/21

[#14303] IRHG - GC Memory Fragmentation? — Charles Thornton <ceo@...>

While working on Chapter 05 and referencing various works

23 messages 2007/12/23
[#14308] Re: IRHG - GC Memory Fragmentation? — Ryan Davis <ryand-ruby@...> 2007/12/23

[#14335] Many external symbols _without_ prefix in libruby object file — Tadashi Saito <shiba@...2.accsnet.ne.jp>

Hi all,

12 messages 2007/12/23

[#14364] RDoc: [FATAL] failed to allocate memory — Martin Duerst <duerst@...>

With revision 14590, I suddenly get an error when I do "make install"

13 messages 2007/12/24

[#14367] replace csv.rb with fastercsv.rb — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

15 messages 2007/12/24
[#14390] Re: replace csv.rb with fastercsv.rb — James Gray <james@...> 2007/12/24

On Dec 24, 2007, at 3:34 AM, NAKAMURA, Hiroshi wrote:

[#14418] Base64 not there makes Rails 2.0.2 fail to load in 1.9.0 — Richard Kilmer <rich@...>

Just re-built latest svn of 1.9.0 and base64.rb is removed. Its

51 messages 2007/12/25
[#14420] Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — Eric Hodel <drbrain@...7.net> 2007/12/25

On Dec 25, 2007, at 07:03 AM, Richard Kilmer wrote:

[#14427] Re: Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — "M. Edward (Ed) Borasky" <znmeb@...> 2007/12/25

Eric Hodel wrote:

[#14431] Re: Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — Dave Thomas <dave@...> 2007/12/25

[#14446] Re: Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — Eric Hodel <drbrain@...7.net> 2007/12/26

On Dec 25, 2007, at 13:35 PM, Dave Thomas wrote:

[#14452] Re: Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — Dave Thomas <dave@...> 2007/12/26

[#14492] Re: Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — Eric Hodel <drbrain@...7.net> 2007/12/27

On Dec 26, 2007, at 06:16 AM, Dave Thomas wrote:

[#14494] Re: Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — Dave Thomas <dave@...> 2007/12/27

[#14503] Re: Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — Richard Kilmer <rich@...> 2007/12/27

[#14505] Re: Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — Charles Oliver Nutter <charles.nutter@...> 2007/12/27

Richard Kilmer wrote:

[#14429] Re: Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — hemant <gethemant@...> 2007/12/25

On Dec 26, 2007 1:01 AM, M. Edward (Ed) Borasky <znmeb@cesmail.net> wrote:

[#14430] Re: Legacy support (Was: Base64 not there makes Rails 2.0.2 fail to load in 1.9.0) — "M. Edward (Ed) Borasky" <znmeb@...> 2007/12/25

hemant wrote:

[#14517] Invalid use of mktime() in Ruby 1.8/1.9 results in incorrect Time objects — Dirkjan Bussink <d.bussink@...>

Hello,

12 messages 2007/12/27

[#14549] multibyte strings & bucket-of-bytes efficiency under 1.9.0 — khaines@...

Like everyone else, I've been testing my stuff under 1.9.0. In general,

38 messages 2007/12/28
[#14560] Re: multibyte strings & bucket-of-bytes efficiency under 1.9.0 — Brent Roman <brent@...> 2007/12/28

[#14573] Re: multibyte strings & bucket-of-bytes efficiency under 1.9.0 — murphy <murphy@...> 2007/12/29

Brent Roman wrote:

[#14603] Re: multibyte strings & bucket-of-bytes efficiency under 1.9.0 — Brent Roman <brent@...> 2007/12/30

[#14617] Re: multibyte strings & bucket-of-bytes efficiency under 1.9.0 — Tanaka Akira <akr@...> 2007/12/31

In article <14544702.post@talk.nabble.com>,

[#14568] Layout of includes in ruby 1.9 — Gonzalo Garramu <ggarra@...>

19 messages 2007/12/29
[#14576] Re: Layout of includes in ruby 1.9 — "Rick DeNatale" <rick.denatale@...> 2007/12/29

On Dec 29, 2007 2:39 AM, Gonzalo Garramu=F1o <ggarra@advancedsl.com.ar> wro=

[#14569] Wide strings to ruby strings — Gonzalo Garramu <ggarra@...>

11 messages 2007/12/29

[#14602] RCR allow indexing last n items — "Michal Suchanek" <hramrach@...>

Hello

15 messages 2007/12/30
[#14609] Re: RCR allow indexing last n items — "David A. Black" <dblack@...> 2007/12/30

Hi --

[#14610] Re: RCR allow indexing last n items — "Michal Suchanek" <hramrach@...> 2007/12/30

On 30/12/2007, David A. Black <dblack@rubypal.com> wrote:

[#14616] Re: RCR allow indexing last n items — "David A. Black" <dblack@...> 2007/12/30

Hi --

[#14621] Module.new(&block) in Ruby 1.9 — murphy <murphy@...>

Hello!

21 messages 2007/12/31
[#14622] Re: Module.new(&block) in Ruby 1.9 — "Cheah Chu Yeow" <chuyeow@...> 2007/12/31

This looks like a related bug with passing block arguments to

[#14633] Re: Module.new(&block) in Ruby 1.9 — murphy <murphy@...> 2007/12/31

Cheah Chu Yeow wrote:

[#14716] Re: Module.new(&block) in Ruby 1.9 — SASADA Koichi <ko1@...> 2008/01/03

Hi,

[#14726] Re: Module.new(&block) in Ruby 1.9 — ts <decoux@...> 2008/01/03

>>>>> "S" == SASADA Koichi <ko1@atdot.net> writes:

[#14728] Re: Module.new(&block) in Ruby 1.9 — SASADA Koichi <ko1@...> 2008/01/03

Hi,

[#16093] Re: Module.new(&block) in Ruby 1.9 — "Jeremy Kemper" <jeremy@...> 2008/04/01

Hi,

Experimental PATCH to improve thread performance

From: Brent Roman <brent@...>
Date: 2007-12-19 02:11:49 UTC
List: ruby-core #14149
The attached patch against Ruby 1.8.6-p110 improves the performance of
multi-threaded applications, especially those that create helper threads
when the parent thread is deeply nested in its call stack.

Totally Bogus Benchmark script #1:
----------------------------

$depth = 0

def outer name
  if ($depth+=1) < 2000
    outer name
  else
    250.times {
      Thread.new do
        inner :inner, name, Thread.current
      end.join
    }
  end
end

def inner innerName, outerName, parent
  Thread.new do
    parent.join
    k = Proc.new {|n0, n1| q = n0.to_s << n1.to_s }
    k[innerName, outerName]
  end
end
   
outer :outer

---------------------

Equally Bogus Benchmark Script #2:
----------------------------

$depth = 0

def outer name
  ball = Thread.current
  inner = Thread.new Thread.current do | outer |
    loop {
      Thread.stop until (Thread.critical=true; ball == inner)
      (ball=outer).run
    }
  end
  2000.times {|i|  
    Thread.stop until (Thread.critical=true; ball == Thread.current)
    (ball=inner).run
  }
end

def recurse someArg
  if ($depth+=1) < 2000
    recurse 3.14159
  else
    outer :outer
  end
end

recurse "top"
-------------------------------

On my 1.5 Ghz Centrino laptop, benchmark #1 executes about twice as fast
after the attached patch is applied.  Benchmark #2 shows a 30% improvement.

Admittedly these benchmarks were contrived, as all benchmarks are,
to demonstrate situations where this patch would yield the greatest
performance
improvement.  However, I don't believe there is any Ruby script that will
execute measurably slower or take more memory after this patch is applied.
(Yes, I'm challenging someone to prove me wrong there :-)

Unpatched, 'C' Ruby allows each thread's backtrace to chain up into the
frames of its parent, frozen at the time the child was first created.
This means that context switches require copying not only the active
thread's
frames, but all of the parent's as well.  Further, creating new Proc
object's
in the child thread requires that "framedup()" copy the parent's frames as
well as the child's.  Moreover, the frozen parent's stack keeps the garbage
collector from releasing objects referenced there, even after those
references are no longer present in the active parent thread as it
continues to execute (or dies).

This patch works by isolating each thread's stack from that of its parent.
There is still just one stack, but when a new thread is created, its current
"ruby_frame" is linked directly back to Ruby's "top_frame".  Thus, each
thread
behaves as through it was started with its own empty stack.  When a context
switch is performed, only the slice of the stack that is accessible by
the active
thread need by copied from the heap.  Whenever it is necessary
to duplicate the active thread's frames, only those are copied, not the
parent's
as well.  This saves both time and space.  The only "cost" is an additional
pointer in the (already large) "struct thread"

If all this seems a bit too good to be true, it just might be.
I've tested the patch against our multi-threaded "killer" app that
managed to crash all unpatched versions of Ruby 1.6.8, 1.8.x, 1.9 and JRuby.
If you've got a multi-threaded test or application, I invite you to
try it against this patch.  Feedback would be very much appreciated.

Yes, there are a couple side effects:

1)  ruby backtraces from child threads will now end at the thread's
creation.
     Frames from other thread's will no longer be included in any backtrace.
     I strongly suspect that Ruby 1.9, JRuby and other "native threaded"
     Ruby implementations will behave this way as well.
     (Can anyone confirm this?)

2)  The 'C'-level stack will become corrupt as slices of it get copied
     into and out of the heap.  If you are using a 'C'-level debugger, its
     backtrace command will get confused after it ascends the stack
     into frames above those of the current Ruby thread.

Background:
I noticed this monolithic stack copying behavior while debugging a
couple segfault causing bugs I'd found in ruby 1.8.6 and 1.6.8.
These resulted in some instances when a child thread
outlived its parents.  (See my recent post:  Continuations on dead
threads ...)

In 1.6.8, the situation is worse.  Without the appropriate version of
this patch,
the "newest" 1.6.8 snapshot will very occasionally crash running these
benchmarks.
The good news is that benchmark #1 runs 5 times faster after 1.6.8 is
patched :-)
Benchmark #2 runs  twice as fast.  If anyone, aside from me, is still
interested
in Ruby v1.6.8, just let me know.  I'll be happy to post a patch for it.

- brent


Attachments (1)

thread18.patch (5.3 KB, text/x-diff)
Index: intern.h
===================================================================
RCS file: /home/cvs/ESP/gen2/software/ruby/ruby-1.8.6-mbari/intern.h,v
retrieving revision 1.1
diff -u -r1.1 intern.h
--- intern.h	18 Dec 2007 01:10:32 -0000	1.1
+++ intern.h	19 Dec 2007 00:17:06 -0000
@@ -238,7 +238,7 @@
 /* gc.c */
 NORETURN(void rb_memerror __((void)));
 int ruby_stack_check _((void));
-int ruby_stack_length _((VALUE**));
+int ruby_stack_length _((VALUE *,VALUE**));
 char *rb_source_filename _((const char*));
 void rb_gc_mark_locations _((VALUE*, VALUE*));
 void rb_mark_tbl _((struct st_table*));
Index: node.h
===================================================================
RCS file: /home/cvs/ESP/gen2/software/ruby/ruby-1.8.6-mbari/node.h,v
retrieving revision 1.1
diff -u -r1.1 node.h
--- node.h	18 Dec 2007 02:18:44 -0000	1.1
+++ node.h	19 Dec 2007 00:17:07 -0000
@@ -408,10 +408,8 @@
 
     VALUE result;
 
-    long   stk_len;
-    long   stk_max;
-    VALUE *stk_ptr;
-    VALUE *stk_pos;
+    long   stk_len, stk_max;
+    VALUE *stk_ptr, *stk_pos, *stk_start;
 #ifdef __ia64
     long   bstr_len;
     long   bstr_max;
Index: gc.c
===================================================================
RCS file: /home/cvs/ESP/gen2/software/ruby/ruby-1.8.6-mbari/gc.c,v
retrieving revision 1.1
diff -u -r1.1 gc.c
--- gc.c	10 Nov 2007 01:08:15 -0000	1.1
+++ gc.c	19 Dec 2007 00:16:27 -0000
@@ -450,14 +500,14 @@
 # define STACK_END (stack_end)
 #endif
 #if defined(sparc) || defined(__sparc__)
-# define STACK_LENGTH  (rb_gc_stack_start - STACK_END + 0x80)
+# define STACK_LENGTH(start)  ((start) - STACK_END + 0x80)
 #elif STACK_GROW_DIRECTION < 0
-# define STACK_LENGTH  (rb_gc_stack_start - STACK_END)
+# define STACK_LENGTH(start)  ((start) - STACK_END)
 #elif STACK_GROW_DIRECTION > 0
-# define STACK_LENGTH  (STACK_END - rb_gc_stack_start + 1)
+# define STACK_LENGTH  (STACK_END - (start) + 1)
 #else
-# define STACK_LENGTH  ((STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END\
-                                           : STACK_END - rb_gc_stack_start + 1)
+# define STACK_LENGTH  ((STACK_END < (start)) ? \
+                         (start) - STACK_END  :  STACK_END - (start) + 1)
 #endif
 #if STACK_GROW_DIRECTION > 0
 # define STACK_UPPER(x, a, b) a
@@ -481,17 +531,17 @@
 #define GC_WATER_MARK 512
 
 #define CHECK_STACK(ret) do {\
-    SET_STACK_END;\
-    (ret) = (STACK_LENGTH > STACK_LEVEL_MAX + GC_WATER_MARK);\
+  SET_STACK_END;\
+  (ret) = (STACK_LENGTH(rb_gc_stack_start) > STACK_LEVEL_MAX + GC_WATER_MARK);\
 } while (0)
 
 int
-ruby_stack_length(p)
-    VALUE **p;
+ruby_stack_length(start, base)
+    VALUE *start, **base;
 {
     SET_STACK_END;
-    if (p) *p = STACK_UPPER(STACK_END, rb_gc_stack_start, STACK_END);
-    return STACK_LENGTH;
+    if (base) *base = STACK_UPPER(STACK_END, start, STACK_END);
+    return STACK_LENGTH(start);
 }
 
 int
@@ -1321,7 +1365,7 @@
 garbage_collect()
 {
     struct gc_list *list;
-    struct FRAME * volatile frame; /* gcc 2.7.2.3 -O2 bug??  */
+    struct FRAME *frame;
     jmp_buf save_regs_gc_mark;
     SET_STACK_END;
 
Index: eval.c
===================================================================
RCS file: /home/cvs/ESP/gen2/software/ruby/ruby-1.8.6-mbari/eval.c,v
retrieving revision 1.2
diff -u -r1.2 eval.c
--- eval.c	2007-09-22 17:01:50.000000000 -0700
+++ ../ruby-1.8.6-mbari/eval.c	2007-12-18 00:18:24.000000000 -0800
@@ -6509,6 +6509,7 @@
 
 	    scope_dup(ruby_scope);
 	    for (tag=prot_tag; tag; tag=tag->prev) {
+                if (tag->tag == PROT_THREAD) break;
 		scope_dup(tag->scope);
 	    }
 	    for (vars = ruby_dyna_vars; vars; vars = vars->next) {
@@ -10216,13 +10324,10 @@
 rb_thread_save_context(th)
     rb_thread_t th;
 {
-    VALUE *pos;
     int len;
     static VALUE tval;
 
-    len = ruby_stack_length(&pos);
-    th->stk_len = 0;
-    th->stk_pos = pos;
+    len = ruby_stack_length(th->stk_start,&th->stk_pos);
     if (len > th->stk_max) {
 	VALUE *ptr = realloc(th->stk_ptr, sizeof(VALUE) * len);
 	if (!ptr) rb_memerror();
@@ -11721,6 +11826,7 @@
     th->result = 0;\
     th->flags = 0;\
 \
+    th->stk_start = rb_gc_stack_start;\
     th->stk_ptr = 0;\
     th->stk_len = 0;\
     th->stk_max = 0;\
@@ -11932,6 +12038,15 @@
 		 "can't start a new thread (frozen ThreadGroup)");
     }
 
+    th->stk_start =   /* establish start of new thread's stack */
+#if STACK_GROW_DIRECTION > 0
+      (VALUE *)ruby_frame;
+#elif STACK_GROW_DIRECTION < 0
+      (VALUE *)(ruby_frame+1);
+#else
+      (VALUE *)(ruby_frame+((VALUE *)(&arg)<rb_gc_stack_start))
+#endif
+
     if (!thread_init) {
 	thread_init = 1;
 #if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE)
@@ -11977,6 +12092,8 @@
     PUSH_TAG(PROT_THREAD);
     if ((state = EXEC_TAG()) == 0) {
 	if (THREAD_SAVE_CONTEXT(th) == 0) {
+            ruby_frame->prev = top_frame;     /* hide parent thread's frames */
+            ruby_frame->tmp = 0;   /* <-- not sure whether this is necessary */           
 	    curr_thread = th;
 	    th->result = (*fn)(arg, th);
 	}
@@ -12090,7 +12207,7 @@
     rb_thread_t th = rb_thread_alloc(klass);
     volatile VALUE *pos;
 
-    pos = th->stk_pos;
+    pos = th->stk_pos;   //brent@mbari.org wants to know what this assignment does?
     rb_obj_call_init(th->thread, argc, argv);
     if (th->stk_pos == 0) {
 	rb_raise(rb_eThreadError, "uninitialized thread - check `%s#initialize'",

In This Thread

Prev Next