ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* Automatic vars and setjmp
@ 2003-09-25 18:34 Mauricio Fernández
  0 siblings, 0 replies; only message in thread
From: Mauricio Fernández @ 2003-09-25 18:34 UTC (permalink / raw
  To: ruby-core


In eval.c:

rb_callcc

    if (THREAD_SAVE_CONTEXT(th)) {
		return th->result;
    }

rb_thread_raise

    if (!rb_thread_dead(curr_thread)) {
		if (THREAD_SAVE_CONTEXT(curr_thread)) {
		    return th->thread;
		}
    }

Is that safe? Couldn't th be stored in a register and hence be undefined
when returning from a longjmp in THREAD_SAVE_CONTEXT?

diff -ru6 ruby-1.8.0.old/eval.c rubyx/eval.c
--- ruby-1.8.0.old/eval.c       2003-09-25 19:57:31.000000000 +0200
+++ rubyx/eval.c        2003-09-25 20:26:37.000000000 +0200
@@ -9648,13 +9648,13 @@
 }

 static VALUE
 rb_thread_raise(argc, argv, th)
     int argc;
     VALUE *argv;
-    rb_thread_t th;
+    volatile rb_thread_t th;
 {
     if (rb_thread_dead(th)) return Qnil;
     if (curr_thread == th) {
        rb_f_raise(argc, argv);
     }

@@ -9819,13 +9819,13 @@

 static VALUE
 rb_callcc(self)
     VALUE self;
 {
     volatile VALUE cont;
-    rb_thread_t th;
+    volatile rb_thread_t th;
     struct tag *tag;
     struct RVarmap *vars;

     THREAD_ALLOC(th);
     cont = Data_Wrap_Struct(rb_cCont, thread_mark, thread_free, th);

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

But what can you do with it?
	-- ubiquitous cry from Linux-user partner

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-09-25 18:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-25 18:34 Automatic vars and setjmp Mauricio Fernández

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).