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

ruby-changes:53779

From: k0kubun <ko1@a...>
Date: Mon, 26 Nov 2018 23:45:44 +0900 (JST)
Subject: [ruby-changes:53779] k0kubun:r65997 (trunk): process.c: try to workaroun SEGV by r65994

k0kubun	2018-11-26 23:45:39 +0900 (Mon, 26 Nov 2018)

  New Revision: 65997

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

  Log:
    process.c: try to workaroun SEGV by r65994
    
    http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480173
    
    It tries to print C backtrace but fails. And core file on the server
    seems to be stopping on the irrelevant place due to its own signal
    handler for the dump.
    
    And I failed to reproduce this SEGV on my machine.
    
    I don't know why it's broken, so let me try this change to investigate
    the reason of SEGV.

  Modified files:
    trunk/internal.h
    trunk/mjit.c
    trunk/mjit.h
    trunk/process.c
Index: internal.h
===================================================================
--- internal.h	(revision 65996)
+++ internal.h	(revision 65997)
@@ -1634,12 +1634,12 @@ VALUE rb_math_sqrt(VALUE); https://github.com/ruby/ruby/blob/trunk/internal.h#L1634
 extern int mjit_enabled;
 VALUE mjit_pause(int wait_p);
 VALUE mjit_resume(void);
-void mjit_finish(void);
+void mjit_clean_files(void);
 #else
 #define mjit_enabled 0
 static inline VALUE mjit_pause(int wait_p){ return Qnil; } /* unreachable */
 static inline VALUE mjit_resume(void){ return Qnil; } /* unreachable */
-static inline void mjit_finish(void){}
+static void mjit_clean_files(void){}
 #endif
 
 /* newline.c */
Index: process.c
===================================================================
--- process.c	(revision 65996)
+++ process.c	(revision 65997)
@@ -2944,7 +2944,13 @@ rb_f_exec(int argc, const VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L2944
 
     execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE);
     eargp = rb_execarg_get(execarg_obj);
-    if (mjit_enabled) mjit_finish(); /* do not leave files or leak children */
+    if (mjit_enabled) {
+        /* TODO: Use mjit_finish() here. We're not doing so because it leads SEGV
+           http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480173 and we don't know why. */
+        mjit_pause(FALSE); /* do not leak children */
+        mjit_clean_files(); /* do not leave files. */
+        mjit_enabled = FALSE; /* MJIT won't work without files deleted above. never JIT-able after exec failure + rescue, for now. */
+    }
     before_exec(); /* stop timer thread before redirects */
     rb_execarg_parent_start(execarg_obj);
     fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name;
Index: mjit.c
===================================================================
--- mjit.c	(revision 65996)
+++ mjit.c	(revision 65997)
@@ -785,6 +785,29 @@ mjit_child_after_fork(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L785
     start_worker();
 }
 
+/* Half-baked version of mjit_finish(). It just deletes MJIT-related files.
+   Caller should disable MJIT because it won't work without the deleted files.
+
+   We want to use mjit_finish() for this function's usage but it's somehow broken like:
+   http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480173 */
+void
+mjit_clean_files(void)
+{
+#ifndef _MSC_VER /* mswin has prebuilt precompiled header */
+    if (!mjit_opts.save_temps && getpid() == pch_owner_pid)
+        remove_file(pch_file);
+
+    xfree(header_file); header_file = NULL;
+#endif
+    xfree(tmp_dir); tmp_dir = NULL;
+    xfree(pch_file); pch_file = NULL;
+
+    mjit_call_p = FALSE;
+    free_list(&unit_queue);
+    free_list(&active_units);
+    free_list(&compact_units);
+}
+
 /* Finish the threads processing units and creating PCH, finalize
    and free MJIT data.  It should be called last during MJIT
    life.  */
@@ -817,19 +840,7 @@ mjit_finish(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L840
     rb_native_cond_destroy(&mjit_worker_wakeup);
     rb_native_cond_destroy(&mjit_gc_wakeup);
 
-#ifndef _MSC_VER /* mswin has prebuilt precompiled header */
-    if (!mjit_opts.save_temps && getpid() == pch_owner_pid)
-        remove_file(pch_file);
-
-    xfree(header_file); header_file = NULL;
-#endif
-    xfree(tmp_dir); tmp_dir = NULL;
-    xfree(pch_file); pch_file = NULL;
-
-    mjit_call_p = FALSE;
-    free_list(&unit_queue);
-    free_list(&active_units);
-    free_list(&compact_units);
+    mjit_clean_files();
     finish_conts();
 
     mjit_enabled = FALSE;
Index: mjit.h
===================================================================
--- mjit.h	(revision 65996)
+++ mjit.h	(revision 65997)
@@ -66,6 +66,7 @@ RUBY_SYMBOL_EXPORT_END https://github.com/ruby/ruby/blob/trunk/mjit.h#L66
 
 extern int mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *funcname, struct rb_call_cache *cc_entries, union iseq_inline_storage_entry *is_entries);
 extern void mjit_init(struct mjit_options *opts);
+extern void mjit_finish(void);
 extern void mjit_gc_start_hook(void);
 extern void mjit_gc_finish_hook(void);
 extern void mjit_free_iseq(const rb_iseq_t *iseq);
@@ -131,6 +132,7 @@ void mjit_child_after_fork(void); https://github.com/ruby/ruby/blob/trunk/mjit.h#L132
 #else /* USE_MJIT */
 static inline struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec){return NULL;}
 static inline void mjit_cont_free(struct mjit_cont *cont){}
+static inline void mjit_finish(void){}
 static inline void mjit_gc_start_hook(void){}
 static inline void mjit_gc_finish_hook(void){}
 static inline void mjit_free_iseq(const rb_iseq_t *iseq){}

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

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