Skip to content

Commit

Permalink
* eval.c (setup_exception): internal exception should be hidden
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed May 18, 2011
1 parent bfb8b12 commit 2082417
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Wed May 18 22:36:43 2011 Nobuyoshi Nakada <[email protected]>

* eval.c (setup_exception): internal exception should be hidden

Wed May 18 20:25:04 2011 KOSAKI Motohiro <[email protected]>

* lib/timeout.rb (Timeout#timeout): don't leak "execution expired"
Expand Down
4 changes: 3 additions & 1 deletion eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,10 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg)
const char *file;
volatile int line = 0;

if (NIL_P(mesg))
if (NIL_P(mesg)) {
mesg = th->errinfo;
if (INTERNAL_EXCEPTION_P(mesg)) JUMP_TAG(TAG_FATAL);
}
if (NIL_P(mesg)) {
mesg = rb_exc_new(rb_eRuntimeError, 0, 0);
}
Expand Down
2 changes: 2 additions & 0 deletions eval_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ NORETURN(void _longjmp(jmp_buf, int));

#define JUMP_TAG(st) TH_JUMP_TAG(GET_THREAD(), (st))

#define INTERNAL_EXCEPTION_P(exc) FIXNUM_P(exc)

enum ruby_tag_type {
RUBY_TAG_RETURN = 0x1,
RUBY_TAG_BREAK = 0x2,
Expand Down
25 changes: 25 additions & 0 deletions test/ruby/test_signal.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'test/unit'
require 'timeout'
require 'tempfile'
require_relative 'envutil'

class TestSignal < Test::Unit::TestCase
Expand Down Expand Up @@ -195,4 +196,28 @@ def test_kill_immediately_before_termination
w.close
assert_equal(r.read, "foo")
end

def test_signal_requiring
t = Tempfile.new(%w"require_ensure_test .rb")
t.puts "sleep"
t.close
error = IO.popen([EnvUtil.rubybin, "-e", <<EOS, t.path, err: :close]) do |child|
th = Thread.new do
begin
require ARGV[0]
ensure
Marshal.dump($!, STDOUT)
end
end
STDOUT.puts
STDOUT.flush
th.join
EOS
child.gets
Process.kill("INT", child.pid)
Marshal.load(child)
end
t.close!
assert_nil(error)
end
end
4 changes: 2 additions & 2 deletions thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ static int rb_threadptr_dead(rb_thread_t *th);

static void rb_check_deadlock(rb_vm_t *vm);

static const VALUE eKillSignal = INT2FIX(0);
static const VALUE eTerminateSignal = INT2FIX(1);
#define eKillSignal INT2FIX(0)
#define eTerminateSignal INT2FIX(1)
static volatile int system_working = 1;

#define closed_stream_error GET_VM()->special_exceptions[ruby_error_closed_stream]
Expand Down

0 comments on commit 2082417

Please sign in to comment.