зеркало из https://github.com/github/ruby.git
Restart timer thread even after preparation failed
If the timer thread is left stopped, memory crash or segfault can happen.
This commit is contained in:
Родитель
f905f694cc
Коммит
de3883e782
11
process.c
11
process.c
|
@ -2905,13 +2905,20 @@ rb_f_exec(int argc, const VALUE *argv)
|
||||||
struct rb_execarg *eargp;
|
struct rb_execarg *eargp;
|
||||||
#define CHILD_ERRMSG_BUFLEN 80
|
#define CHILD_ERRMSG_BUFLEN 80
|
||||||
char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' };
|
char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' };
|
||||||
int err;
|
int err, state;
|
||||||
|
|
||||||
execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE);
|
execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE);
|
||||||
eargp = rb_execarg_get(execarg_obj);
|
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.
|
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 */
|
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;
|
fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name;
|
||||||
|
|
||||||
err = exec_async_signal_safe(eargp, errmsg, sizeof(errmsg));
|
err = exec_async_signal_safe(eargp, errmsg, sizeof(errmsg));
|
||||||
|
|
|
@ -2397,6 +2397,15 @@ EOS
|
||||||
r.close if r
|
r.close if r
|
||||||
end if defined?(fork)
|
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
|
def test_many_args
|
||||||
bug11418 = '[ruby-core:70251] [Bug #11418]'
|
bug11418 = '[ruby-core:70251] [Bug #11418]'
|
||||||
assert_in_out_err([], <<-"end;", ["x"]*256, [], bug11418, timeout: 60)
|
assert_in_out_err([], <<-"end;", ["x"]*256, [], bug11418, timeout: 60)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче