summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-26 09:05:28 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-26 09:05:28 +0000
commit62a3e7a33b24f851bb6c9658925a4bf30655e70c (patch)
treeefad12d478eec64c9ee17ef1594b0076b0ac0890
parent9e717416b44d92baf52f9e87d32725454eb3487c (diff)
vm_eval.c: strange message in eval
* vm_eval.c (eval_string_with_cref): remove unnecessary location from exception backtrace in eval. [ruby-core:84434] [Bug #14229] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_exception.rb5
-rw-r--r--vm_eval.c45
2 files changed, 10 insertions, 40 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index 3e9f4d1bc2..76be7f0ac2 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -1101,6 +1101,11 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
end;
end
+ def test_backtrace_in_eval
+ bug = '[ruby-core:84434] [Bug #14229]'
+ assert_in_out_err(['-e', 'eval("raise")'], "", [], /^\(eval\):1:/, bug)
+ end
+
def test_full_message
test_method = "def foo; raise 'testerror'; end"
diff --git a/vm_eval.c b/vm_eval.c
index a62e2a7a62..5470a92264 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1243,33 +1243,14 @@ rb_each(VALUE obj)
}
static VALUE
-adjust_backtrace_in_eval(const rb_execution_context_t *ec, VALUE errinfo)
-{
- VALUE errat = rb_get_backtrace(errinfo);
- VALUE mesg = rb_attr_get(errinfo, id_mesg);
- if (RB_TYPE_P(errat, T_ARRAY)) {
- VALUE bt2 = rb_ec_backtrace_str_ary(ec, 0, 0);
- if (RARRAY_LEN(bt2) > 0) {
- if (RB_TYPE_P(mesg, T_STRING) && !RSTRING_LEN(mesg)) {
- rb_ivar_set(errinfo, id_mesg, RARRAY_AREF(errat, 0));
- }
- RARRAY_ASET(errat, 0, RARRAY_AREF(bt2, 0));
- }
- }
- return errinfo;
-}
-
-static VALUE
eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_arg,
VALUE filename, int lineno)
{
- int state;
- VALUE result = Qundef;
rb_execution_context_t *ec = GET_EC();
struct rb_block block;
const struct rb_block *base_block;
- volatile VALUE file;
- volatile int line;
+ VALUE file;
+ int line;
file = filename ? filename : rb_source_location(&lineno);
line = lineno;
@@ -1318,7 +1299,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
iseq = rb_iseq_compile_with_option(src, fname, realpath, INT2FIX(line), base_block, Qnil);
if (!iseq) {
- rb_exc_raise(adjust_backtrace_in_eval(ec, ec->errinfo));
+ rb_exc_raise(ec->errinfo);
}
/* TODO: what the code checking? */
@@ -1344,24 +1325,8 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
}
}
- if (file != Qundef) {
- /* kick */
- return vm_exec(ec);
- }
-
- EC_PUSH_TAG(ec);
- if ((state = EC_EXEC_TAG()) == TAG_NONE) {
- result = vm_exec(ec);
- }
- EC_POP_TAG();
-
- if (state) {
- if (state == TAG_RAISE) {
- adjust_backtrace_in_eval(ec, ec->errinfo);
- }
- EC_JUMP_TAG(ec, state);
- }
- return result;
+ /* kick */
+ return vm_exec(ec);
}
static VALUE