[前][次][番号順一覧][スレッド一覧]

ruby-changes:44947

From: shugo <ko1@a...>
Date: Thu, 8 Dec 2016 08:27:56 +0900 (JST)
Subject: [ruby-changes:44947] shugo:r57020 (trunk): Add clang volatile fixes from FreeBSD and NetBSD.

shugo	2016-12-08 08:27:51 +0900 (Thu, 08 Dec 2016)

  New Revision: 57020

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57020

  Log:
    Add clang volatile fixes from FreeBSD and NetBSD.
    
    Use volatile instead of optnone to avoid optimization which causes
    segmentation faults.
    Patch by Dimitry Andric.  [ruby-core:78531] [Bug #13014]

  Modified files:
    trunk/cont.c
    trunk/eval.c
    trunk/eval_error.c
    trunk/thread.c
    trunk/vm_core.h
    trunk/vm_eval.c
    trunk/vm_trace.c
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 57019)
+++ eval_error.c	(revision 57020)
@@ -73,10 +73,10 @@ error_print(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L73
 }
 
 void
-rb_threadptr_error_print(rb_thread_t *th, VALUE errinfo)
+rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo)
 {
     volatile VALUE errat = Qundef;
-    int raised_flag = th->raised_flag;
+    volatile int raised_flag = th->raised_flag;
     volatile VALUE eclass = Qundef, e = Qundef;
     const char *volatile einfo;
     volatile long elen;
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 57019)
+++ vm_core.h	(revision 57020)
@@ -1562,7 +1562,7 @@ void rb_threadptr_unlock_all_locking_mut https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1562
 void rb_threadptr_pending_interrupt_clear(rb_thread_t *th);
 void rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v);
 int rb_threadptr_pending_interrupt_active_p(rb_thread_t *th);
-void rb_threadptr_error_print(rb_thread_t *th, VALUE errinfo);
+void rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo);
 
 #define RUBY_VM_CHECK_INTS(th) ruby_vm_check_ints(th)
 static inline void
Index: vm_trace.c
===================================================================
--- vm_trace.c	(revision 57019)
+++ vm_trace.c	(revision 57020)
@@ -389,7 +389,7 @@ rb_suppress_tracing(VALUE (*func)(VALUE) https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L389
     volatile int raised;
     volatile int outer_state;
     VALUE result = Qnil;
-    rb_thread_t *th = GET_THREAD();
+    rb_thread_t *volatile th = GET_THREAD();
     int state;
     const int tracing = th->trace_arg ? 1 : 0;
     rb_trace_arg_t dummy_trace_arg;
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 57019)
+++ vm_eval.c	(revision 57020)
@@ -1280,7 +1280,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1280
 {
     int state;
     VALUE result = Qundef;
-    rb_thread_t *th = GET_THREAD();
+    rb_thread_t *volatile th = GET_THREAD();
     struct rb_block block;
     const struct rb_block *base_block;
     volatile VALUE file;
@@ -1997,7 +1997,7 @@ rb_catch(const char *tag, VALUE (*func)( https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1997
     return rb_catch_obj(vtag, func, data);
 }
 
-static VALUE vm_catch_protect(VALUE, rb_block_call_func *, VALUE, int *, rb_thread_t *);
+static VALUE vm_catch_protect(VALUE, rb_block_call_func *, VALUE, int *, rb_thread_t *volatile);
 
 VALUE
 rb_catch_obj(VALUE t, VALUE (*func)(), VALUE data)
@@ -2018,11 +2018,11 @@ rb_catch_protect(VALUE t, rb_block_call_ https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2018
 
 static VALUE
 vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
-		 int *stateptr, rb_thread_t *th)
+		 int *stateptr, rb_thread_t *volatile th)
 {
     int state;
     VALUE val = Qnil;		/* OK */
-    rb_control_frame_t *saved_cfp = th->cfp;
+    rb_control_frame_t *volatile saved_cfp = th->cfp;
 
     TH_PUSH_TAG(th);
 
Index: eval.c
===================================================================
--- eval.c	(revision 57019)
+++ eval.c	(revision 57020)
@@ -813,7 +813,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), V https://github.com/ruby/ruby/blob/trunk/eval.c#L813
 {
     int state;
     rb_thread_t *th = GET_THREAD();
-    rb_control_frame_t *cfp = th->cfp;
+    rb_control_frame_t *volatile cfp = th->cfp;
     volatile VALUE result = Qfalse;
     volatile VALUE e_info = th->errinfo;
     va_list args;
@@ -879,7 +879,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE https://github.com/ruby/ruby/blob/trunk/eval.c#L879
     volatile VALUE result = Qnil;
     volatile int status;
     rb_thread_t *th = GET_THREAD();
-    rb_control_frame_t *cfp = th->cfp;
+    rb_control_frame_t *volatile cfp = th->cfp;
     struct rb_vm_protect_tag protect_tag;
     rb_jmpbuf_t org_jmpbuf;
 
Index: cont.c
===================================================================
--- cont.c	(revision 57019)
+++ cont.c	(revision 57020)
@@ -161,7 +161,7 @@ static VALUE rb_eFiberError; https://github.com/ruby/ruby/blob/trunk/cont.c#L161
     if (!(ptr)) rb_raise(rb_eFiberError, "uninitialized fiber"); \
 } while (0)
 
-NOINLINE(static VALUE cont_capture(volatile int *stat));
+NOINLINE(static VALUE cont_capture(int *volatile stat));
 
 #define THREAD_MUST_BE_RUNNING(th) do { \
 	if (!(th)->tag) rb_raise(rb_eThreadError, "not running thread");	\
@@ -470,13 +470,9 @@ cont_new(VALUE klass) https://github.com/ruby/ruby/blob/trunk/cont.c#L470
 }
 
 static VALUE
-cont_capture(volatile int *stat)
-#if defined(__clang__) && \
-    __clang_major__ == 3 && __clang_minor__ == 8 && __clang_patch__ == 0
-__attribute__ ((optnone))
-#endif
+cont_capture(int *volatile stat)
 {
-    rb_context_t *cont;
+    rb_context_t *volatile cont;
     rb_thread_t *th = GET_THREAD();
     volatile VALUE contval;
 
Index: thread.c
===================================================================
--- thread.c	(revision 57019)
+++ thread.c	(revision 57020)
@@ -466,8 +466,8 @@ rb_threadptr_unlock_all_locking_mutexes( https://github.com/ruby/ruby/blob/trunk/thread.c#L466
 void
 rb_thread_terminate_all(void)
 {
-    rb_thread_t *th = GET_THREAD(); /* main thread */
-    rb_vm_t *vm = th->vm;
+    rb_thread_t *volatile th = GET_THREAD(); /* main thread */
+    rb_vm_t *volatile vm = th->vm;
     volatile int sleeping = 0;
 
     if (vm->main_thread != th) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]