Skip to content

Infinite loop generated by using any_instance and dup #120

Closed
tfwright opened this Issue Mar 27, 2012 · 14 comments

6 participants

@tfwright

I believe I've run into a bug while trying to get #119 to work. The following code causes the ruby process to hang, eventually throwing Ruby stack level too deep

it "should play nicely with dup" do
  Object.any_instance.stub(:some_method)
  o = Object.new
  o.some_method
  o.dup.some_method
end
@dchelimsky
RSpec member

@kaiwren do you have time to look at this?

@ags
ags commented Mar 28, 2012

+1, encountered this today.

@kaiwren
kaiwren commented Mar 28, 2012

@dchelimsky Sure, I will, no problem.

@kaiwren
kaiwren commented Mar 28, 2012

Hey @preethiramdev, this was the issue I was telling you about.

@jmazzi
jmazzi commented Mar 28, 2012

Just for a little more insight, this seems to basically cause a fork bomb until all memory is exhausted. I recommend testing this with a wrapper script like this to limit the amount of memory it can consume:

# 500 MB
ulimit -Sv 500000
rspec spec/blah_spec.rb
@preethiramdev

@tfwright Ive been able to replicate this. Will probably not get much done over the weekend tho so will start looking into this on Monday.

@jmazzi Will try that

@kaiwren
kaiwren commented Apr 23, 2012

@dchelimsky I'm helping a few of my colleagues get used to contributing via #124 and #120 - it's taking a little longer than expected. If this is a blocker for an upcoming release, please let me know and I'll fix them myself.

@dchelimsky
RSpec member

This is not a blocker. We can release this fix as a patch release of 2.9 or 2.10, whichever is current when this gets done.

@kaiwren
@kaiwren kaiwren added a commit to c42engineering/rspec-mocks that referenced this issue May 19, 2012
@kaiwren kaiwren Replicating Issue #120 7d85604
@kaiwren kaiwren added a commit to c42engineering/rspec-mocks that referenced this issue May 20, 2012
@kaiwren kaiwren Issue #120: Under any_instance, modify #dup to remove the mock proxy 5de6500
@kaiwren
kaiwren commented May 20, 2012

See pull request #138

@dchelimsky
RSpec member

Closed by #138.

@dchelimsky dchelimsky closed this May 23, 2012
@jmazzi
jmazzi commented May 23, 2012

Thanks, @kaiwren!

@kaiwren
kaiwren commented May 23, 2012

@jmazzi You're welcome. In fact, I'm sorry I took this long to get this sorted. I hope it wasn't too much of an inconvenience.

@jmazzi
jmazzi commented May 23, 2012

@kaiwren nope, we worked around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.