ruby-changes:60079
From: nagachika <ko1@a...>
Date: Sat, 15 Feb 2020 18:13:02 +0900 (JST)
Subject: [ruby-changes:60079] 12c7321d75 (ruby_2_6): merge revision(s) 95ab9cd8f453099d7649dc0e0eec55ea891340f5: [Backport #16624]
https://git.ruby-lang.org/ruby.git/commit/?id=12c7321d75 From 12c7321d758c736d42dbbd36c74628f7a243851e Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Sat, 15 Feb 2020 09:12:47 +0000 Subject: merge revision(s) 95ab9cd8f453099d7649dc0e0eec55ea891340f5: [Backport #16624] Restart timer thread even after preparation failed If the timer thread is left stopped, memory crash or segfault can happen. [Bug #16624] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e diff --git a/process.c b/process.c index d629dd9..47f4771 100644 --- a/process.c +++ b/process.c @@ -2943,13 +2943,20 @@ rb_f_exec(int argc, const VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L2943 struct rb_execarg *eargp; #define CHILD_ERRMSG_BUFLEN 80 char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' }; - int err; + int err, state; execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE); eargp = rb_execarg_get(execarg_obj); if (mjit_enabled) mjit_finish(FALSE); /* avoid leaking resources, and do not leave files. XXX: JIT-ed handle can leak after exec error is rescued. */ before_exec(); /* stop timer thread before redirects */ - rb_execarg_parent_start(execarg_obj); + + rb_protect(rb_execarg_parent_start1, execarg_obj, &state); + if (state) { + execarg_parent_end(execarg_obj); + after_exec(); /* restart timer thread */ + rb_jump_tag(state); + } + fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name; err = exec_async_signal_safe(eargp, errmsg, sizeof(errmsg)); diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index b2f1ad7..0b43c6b 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -2387,6 +2387,15 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L2387 r.close if r end if defined?(fork) + def test_rescue_exec_fail + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + assert_raise(Errno::ENOENT) do + exec("", in: "") + end + end; + end + def test_many_args bug11418 = '[ruby-core:70251] [Bug #11418]' assert_in_out_err([], <<-"end;", ["x"]*256, [], bug11418, timeout: 60) diff --git a/version.h b/version.h index 4c8fd64..2b2fd53 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1 #define RUBY_VERSION "2.6.6" #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 124 +#define RUBY_PATCHLEVEL 125 -#define RUBY_RELEASE_YEAR 2019 -#define RUBY_RELEASE_MONTH 12 -#define RUBY_RELEASE_DAY 18 +#define RUBY_RELEASE_YEAR 2020 +#define RUBY_RELEASE_MONTH 2 +#define RUBY_RELEASE_DAY 15 #include "ruby/version.h" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/