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

ruby-changes:48721

From: usa <ko1@a...>
Date: Sat, 18 Nov 2017 17:25:33 +0900 (JST)
Subject: [ruby-changes:48721] usa:r60837 (trunk): Cannot call rb_thread_call_with{out, }_gvl before running VM

usa	2017-11-18 17:25:29 +0900 (Sat, 18 Nov 2017)

  New Revision: 60837

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

  Log:
    Cannot call rb_thread_call_with{out,}_gvl before running VM
    
    * dir.c (opendir_without_gvl, with_gvl_gc_for_fd, opendir_at): check the VM is
      already initialized before calling rb_thread_call_with{out,}_gvl().
      [Bug #14115]

  Modified files:
    trunk/dir.c
Index: dir.c
===================================================================
--- dir.c	(revision 60836)
+++ dir.c	(revision 60837)
@@ -76,6 +76,8 @@ char *strchr(char*,char); https://github.com/ruby/ruby/blob/trunk/dir.c#L76
 
 #include "ruby/util.h"
 
+#define vm_initialized rb_cThread
+
 /* define system APIs */
 #ifdef _WIN32
 #undef chdir
@@ -501,11 +503,15 @@ nogvl_opendir(void *ptr) https://github.com/ruby/ruby/blob/trunk/dir.c#L503
 static DIR *
 opendir_without_gvl(const char *path)
 {
-    union { const char *in; void *out; } u;
+    if (vm_initialized) {
+	union { const char *in; void *out; } u;
 
-    u.in = path;
+	u.in = path;
 
-    return rb_thread_call_without_gvl(nogvl_opendir, u.out, RUBY_UBF_IO, 0);
+	return rb_thread_call_without_gvl(nogvl_opendir, u.out, RUBY_UBF_IO, 0);
+    }
+    else
+	return opendir(path);
 }
 
 /*
@@ -1420,7 +1426,10 @@ with_gvl_gc_for_fd(void *ptr) https://github.com/ruby/ruby/blob/trunk/dir.c#L1426
 static int
 gc_for_fd_with_gvl(int e)
 {
-    return (int)(VALUE)rb_thread_call_with_gvl(with_gvl_gc_for_fd, &e);
+    if (vm_initialized)
+	return (int)(VALUE)rb_thread_call_with_gvl(with_gvl_gc_for_fd, &e);
+    else
+	return rb_gc_for_fd(e) ? Qtrue : Qfalse;
 }
 
 static void *
@@ -1471,7 +1480,10 @@ opendir_at(int basefd, const char *path) https://github.com/ruby/ruby/blob/trunk/dir.c#L1480
     oaa.basefd = basefd;
     oaa.path = path;
 
-    return rb_thread_call_without_gvl(nogvl_opendir_at, &oaa, RUBY_UBF_IO, 0);
+    if (vm_initialized)
+	return rb_thread_call_without_gvl(nogvl_opendir_at, &oaa, RUBY_UBF_IO, 0);
+    else
+	return nogvl_opendir_at(&oaa);
 }
 
 static DIR *

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

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