Project

General

Profile

Actions

Bug #11430

closed

Updated by cesario (Franck Verrot) almost 10 years ago

Andrew Wong wrote:

I had something like the following in my spec. While not great code design, it does successfully crash Ruby.

let(:my_hash) do
  {
    key_one: 'val_one'
  }
end

subject { post :create, my_hash, format: :json }

context 'with the optional key_two field defined' do
  let(:my_hash) { my_hash.merge!(key_two: 'val_two') }

  it 'successfully posts' do
    expect(subject.status).to eq 200
  end
end

I can reproduce this if I run rspec your_source.rb, but not with ruby /path/to/rspec your_source.rb.

Running the later outputs this:

     Failure/Error: let(:my_hash) { my_hash.merge!(key_two: 'val_two') }
     SystemStackError:
       stack level too deep

HTH.

Updated by andrewchhwong (Andrew Wong) about 9 years ago

Not sure what to do here. Do random issues like this get triaged? Or sitting around like this is typical?

Updated by normalperson (Eric Wong) about 9 years ago

wrote:

Not sure what to do here. Do random issues like this get triaged? Or sitting around like this is typical?

Most of us are volunteers and I find it helpful for reporters to
send reminders every once in a while (once every few weeks is
fine, depending on urgency).

Can you test on a newer version of Ruby?
Or reproduce it outside of rspec?
Having an isolated test case which works with a standard Ruby
install will help us immensely. Thank you.

Updated by dstosik (David Stosik) about 8 years ago

I believe this is related to an incorrect use of RSpec's let, and has nothing to do with Ruby. (=> not a bug here?)

When you write let(:my_hash) { my_hash.merge!(key_two: 'val_two') }, you override :my_hash in that local context, and forget how it was defined before that. You end up with a recursion, as trying to instantiate my_hash will run your block, that needs to evaluate my_hash (run the block again, and so on and so forth, ad aeternam - actually just until the stack explodes).

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

  • Description updated (diff)
  • Status changed from Open to Feedback

Updated by wanabe (_ wanabe) about 8 years ago

  • Related to : [BUG] vm_call_cfunc - cfp consistency error added

Updated by wanabe (_ wanabe) about 8 years ago

  • Related to : Infinite recursion with define_method may cause silent SEGV or cfp consistency error added

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

  • Related to deleted (: Infinite recursion with define_method may cause silent SEGV or cfp consistency error)

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

  • Has duplicate : Infinite recursion with define_method may cause silent SEGV or cfp consistency error added

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

  • Has duplicate deleted (: Infinite recursion with define_method may cause silent SEGV or cfp consistency error)

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

  • Related to : Infinite recursion with define_method may cause silent SEGV or cfp consistency error added

Updated by jeremyevans0 (Jeremy Evans) almost 6 years ago

  • Status changed from Feedback to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0