Issue #7556 has been updated by shugo (Shugo Maeda).

Assignee changed from shugo (Shugo Maeda) to ko1 (Koichi Sasada)

usa (Usaku NAKAMURA) wrote:
> 1) Error:
> test_refine_recursion(TestRefinement):
> NoMethodError: undefined method `recursive_length' for "oo":String
>     C:/Users/usa/ruby/test/ruby/test_refinement.rb:567:in `recursive_length'
>     <main>:in `<main>'
>     C:/Users/usa/ruby/test/ruby/test_refinement.rb:806:in `eval'
>     C:/Users/usa/ruby/test/ruby/test_refinement.rb:806:in `eval_using'
>     C:/Users/usa/ruby/test/ruby/test_refinement.rb:574:in `test_refine_recursion'

To avoid an infinite loop by super in a refinement, ci->call is used to distinguish super calls from normal calls,
and if it's a super call, skip the same method.
However, VC++ optimizes vm_call_general and vm_call_super_method into the same method because they have the same definition, so ci->call cannot be used to distinguish super calls from normal calls.  How intelligent VC++ is!

I've found that the following hack fixes the problem:

static VALUE
vm_call_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci)
{
#ifdef _WIN32
    volatile int x = 0; /* to avoid VC++ optimization which makes
                           vm_call_super_method as an alias of
                           vm_call_general! */
#endif
    return vm_call_method(th, reg_cfp, ci);
}   

Sasada-san, do you accept this ugly hack, or do you come up with a neat solution?

----------------------------------------
Bug #7556: test error on refinement
https://bugs.ruby-lang.org/issues/7556#change-34702

Author: usa (Usaku NAKAMURA)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: ext
Target version: 2.0.0
ruby -v: ruby -v: ruby 2.0.0dev (2012-12-13 trunk 38354) [x64-mswin64_100]


  1) Error:
test_refine_recursion(TestRefinement):
NoMethodError: undefined method `recursive_length' for "oo":String
    C:/Users/usa/ruby/test/ruby/test_refinement.rb:567:in `recursive_length'
    <main>:in `<main>'
    C:/Users/usa/ruby/test/ruby/test_refinement.rb:806:in `eval'
    C:/Users/usa/ruby/test/ruby/test_refinement.rb:806:in `eval_using'
    C:/Users/usa/ruby/test/ruby/test_refinement.rb:574:in `test_refine_recursion'


On my box this error is 100% reproducible, but I also know that RubyCI and
RubyInstaller CI don't report this error.
I've heard that nobu reproduced this bug on x86_64-dawrin, but I don't know
the detail of his environment.

# Once I wrote the detail of my debuggin, but it is lost by accidenal reboot
# of my PC.
# I have no energy to rewrite it, because writing long English sentences
# irritates me, especially after seeing mails which reproach our native
# language.


-- 
http://bugs.ruby-lang.org/