path: root/bootstraptest
diff options
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-22 09:32:56 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-22 09:32:56 +0000
commitc4bc9b575898ba352d0fea8289ebcaf8921dacd1 (patch)
tree5974195d1c0a004072980018cbdfda08b831e727 /bootstraptest
parent471d8d2586d984fd70f6837b117d6f275201204b (diff)
* iseq.c, vm_eval.c: set th->base_block properly.
th->base_block is information for (a) parsing, (b) compiling and (c) setting up the frame to execute the program passed by `eval' method. For example, (1) parser need to know up-level variables to detect it is variable or method without paren. Befor (a), (b) and (c), VM set th->base_block by passed bindng (or previous frame information). After execute (a), (b) and (c), VM should clear th->base_block. However, if (a), (b) or (c) raises an exception, then th->base_block is not cleared. Problem is that the uncleared value th->balo_block is used for irrelevant iseq compilation. It causes SEGV or critical error. I tried to solve this problem: to clear them before exception, but finally I found out that it is difficult to do it (Ruby program can be run in many places). Because of this background, I set th->base_block before compiling iseq and restore it after compiling. Basically, th->base_block is dirty hack (similar to global variable) and this patch is also dirty. * bootstraptest/test_eval.rb: add a test for above. * internal.h: remove unused decl. * iseq.c (rb_iseq_compile_with_option): add base_block parameter. set th->base_block before compation and restore it after compilation. * ruby.c (require_libraries): pass 0 as base_block instead of setting th->base_block * tool/compile_prelude.rb (prelude_eval): apply above changes. * vm.c, vm_eval.c: ditto. * vm_core.h: add comments. git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bootstraptest')
1 files changed, 10 insertions, 0 deletions
diff --git a/bootstraptest/test_eval.rb b/bootstraptest/test_eval.rb
index 18d4d6f..aab1a7b 100644
--- a/bootstraptest/test_eval.rb
+++ b/bootstraptest/test_eval.rb
@@ -318,3 +318,13 @@ assert_normal_exit %q{
eval "class C; @@h = #{hash.inspect}; end"
}, '[ruby-core:25714]'
+assert_normal_exit %q{
+ begin
+ eval("# encoding:utf-16le\nfoo")
+ rescue Exception => e
+ p e
+ RubyVM::InstructionSequence.compile("p:hello")
+ end
+}, 'check escaping the internal value th->base_block'