1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2017-11-18 08:25:29 +00:00
parent db54a07c75
commit 4f83ca015d

22
dir.c
View file

@ -76,6 +76,8 @@ char *strchr(char*,char);
#include "ruby/util.h"
#define vm_initialized rb_cThread
/* define system APIs */
#ifdef _WIN32
#undef chdir
@ -501,11 +503,15 @@ nogvl_opendir(void *ptr)
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)
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)
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 *