Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Fix SystemStackError (stack level too deep) in GemHelper#sh_with_code #6657

Merged
merged 2 commits into from
Aug 15, 2018

Conversation

hibariya
Copy link
Contributor

@hibariya hibariya commented Aug 8, 2018

Hello. I found a method which raises SystemStackError by chance.

What was the end-user problem that led to this PR?

The method always calls itself recursively like as follows:

irb(main):006:0> require './lib/bundler/gem_helper'
=> true
irb(main):007:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
Traceback (most recent call last):
       16: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       15: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       14: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       13: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       12: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       11: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       10: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        9: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        8: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        7: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        6: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        5: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        4: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        3: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        2: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        1: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
SystemStackError (stack level too deep)

What was your diagnosis of the problem?

I think that it can be supposed that sh_with_status should be called rather than sh_with_code because Process::Status#exitstatus is called later on.
(related to #6036)

After this changes, the result of calling the method is as follows:

irb(main):011:0> load './lib/bundler/gem_helper.rb'
=> true
irb(main):012:0>
irb(main):013:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
=> ["bin\nbundler.gemspec\nCHANGELOG.md\nCODE_OF_CONDUCT.md\ndoc\nexe\nGemfile\nGemfile.lock\nlib\nLICENSE.md\nman\nRakefile\nREADME.md\nspec\ntask\n", 0]

I am not sure if I could remove the method since I cannot have confidence that the method is not used anymore. So I simply fixed it.

The method always calls itself recursively. It can be supposed that
`sh_with_status` should be called rather than `sh_with_code` because
Process::Status is called later on.
@ghost
Copy link

ghost commented Aug 8, 2018

Thanks for opening a pull request and helping make Bundler better! Someone from the Bundler team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.

We use Travis CI to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of Travis CI in the PR status window below.

If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #bundler channel on Slack.

For more information about contributing to the Bundler project feel free to review our CONTRIBUTING guide

@colby-swandale
Copy link
Member

Searching through src, it doesn't look like the method is being used anymore. We can probably remove this method.

@hibariya
Copy link
Contributor Author

@colby-swandale Thank you for your response. That's make sense. I have removed the method.

@segiddins
Copy link
Member

👍🏻

@colby-swandale
Copy link
Member

Thank you so much!

@bundlerbot r+

@bundlerbot
Copy link
Collaborator

📌 Commit 88ea68f has been approved by colby-swandale

@bundlerbot
Copy link
Collaborator

⌛ Testing commit 88ea68f with merge 2c2f01a...

bundlerbot added a commit that referenced this pull request Aug 11, 2018
Fix SystemStackError (stack level too deep) in GemHelper#sh_with_code

Hello. I found a method which raises SystemStackError by chance.

### What was the end-user problem that led to this PR?

The method always calls itself recursively like as follows:

```
irb(main):006:0> require './lib/bundler/gem_helper'
=> true
irb(main):007:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
Traceback (most recent call last):
       16: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       15: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       14: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       13: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       12: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       11: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       10: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        9: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        8: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        7: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        6: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        5: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        4: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        3: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        2: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        1: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
SystemStackError (stack level too deep)
```

### What was your diagnosis of the problem?

I think that it can be supposed that `sh_with_status` should be called rather than `sh_with_code` because Process::Status#exitstatus is called later on.
(related to #6036)

After this changes, the result of calling the method is as follows:

```
irb(main):011:0> load './lib/bundler/gem_helper.rb'
=> true
irb(main):012:0>
irb(main):013:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
=> ["bin\nbundler.gemspec\nCHANGELOG.md\nCODE_OF_CONDUCT.md\ndoc\nexe\nGemfile\nGemfile.lock\nlib\nLICENSE.md\nman\nRakefile\nREADME.md\nspec\ntask\n", 0]
```

I am not sure if I could remove the method since I cannot have confidence that the method is not used anymore. So I simply fixed it.
@bundlerbot
Copy link
Collaborator

💔 Test failed - status-travis

@hibariya
Copy link
Contributor Author

The test seems failed due to timeout 😢

@colby-swandale
Copy link
Member

@bundlerbot retry

@bundlerbot
Copy link
Collaborator

⌛ Testing commit 88ea68f with merge b828a7b...

bundlerbot added a commit that referenced this pull request Aug 12, 2018
Fix SystemStackError (stack level too deep) in GemHelper#sh_with_code

Hello. I found a method which raises SystemStackError by chance.

### What was the end-user problem that led to this PR?

The method always calls itself recursively like as follows:

```
irb(main):006:0> require './lib/bundler/gem_helper'
=> true
irb(main):007:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
Traceback (most recent call last):
       16: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       15: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       14: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       13: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       12: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       11: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       10: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        9: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        8: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        7: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        6: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        5: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        4: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        3: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        2: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        1: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
SystemStackError (stack level too deep)
```

### What was your diagnosis of the problem?

I think that it can be supposed that `sh_with_status` should be called rather than `sh_with_code` because Process::Status#exitstatus is called later on.
(related to #6036)

After this changes, the result of calling the method is as follows:

```
irb(main):011:0> load './lib/bundler/gem_helper.rb'
=> true
irb(main):012:0>
irb(main):013:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
=> ["bin\nbundler.gemspec\nCHANGELOG.md\nCODE_OF_CONDUCT.md\ndoc\nexe\nGemfile\nGemfile.lock\nlib\nLICENSE.md\nman\nRakefile\nREADME.md\nspec\ntask\n", 0]
```

I am not sure if I could remove the method since I cannot have confidence that the method is not used anymore. So I simply fixed it.
@bundlerbot
Copy link
Collaborator

💔 Test failed - status-travis

@colby-swandale
Copy link
Member

@bundlerbot retry

@bundlerbot
Copy link
Collaborator

⌛ Testing commit 88ea68f with merge 5b24ecf...

bundlerbot added a commit that referenced this pull request Aug 12, 2018
Fix SystemStackError (stack level too deep) in GemHelper#sh_with_code

Hello. I found a method which raises SystemStackError by chance.

### What was the end-user problem that led to this PR?

The method always calls itself recursively like as follows:

```
irb(main):006:0> require './lib/bundler/gem_helper'
=> true
irb(main):007:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
Traceback (most recent call last):
       16: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       15: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       14: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       13: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       12: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       11: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       10: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        9: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        8: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        7: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        6: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        5: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        4: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        3: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        2: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        1: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
SystemStackError (stack level too deep)
```

### What was your diagnosis of the problem?

I think that it can be supposed that `sh_with_status` should be called rather than `sh_with_code` because Process::Status#exitstatus is called later on.
(related to #6036)

After this changes, the result of calling the method is as follows:

```
irb(main):011:0> load './lib/bundler/gem_helper.rb'
=> true
irb(main):012:0>
irb(main):013:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
=> ["bin\nbundler.gemspec\nCHANGELOG.md\nCODE_OF_CONDUCT.md\ndoc\nexe\nGemfile\nGemfile.lock\nlib\nLICENSE.md\nman\nRakefile\nREADME.md\nspec\ntask\n", 0]
```

I am not sure if I could remove the method since I cannot have confidence that the method is not used anymore. So I simply fixed it.
@bundlerbot
Copy link
Collaborator

💔 Test failed - status-travis

@hibariya
Copy link
Contributor Author

The tests are still failing. Is there anything I can help with?

@colby-swandale
Copy link
Member

@bundlerbot retry

@bundlerbot
Copy link
Collaborator

⌛ Testing commit 88ea68f with merge c9c73cf...

bundlerbot added a commit that referenced this pull request Aug 15, 2018
Fix SystemStackError (stack level too deep) in GemHelper#sh_with_code

Hello. I found a method which raises SystemStackError by chance.

### What was the end-user problem that led to this PR?

The method always calls itself recursively like as follows:

```
irb(main):006:0> require './lib/bundler/gem_helper'
=> true
irb(main):007:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
Traceback (most recent call last):
       16: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       15: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       14: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       13: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       12: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       11: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       10: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        9: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        8: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        7: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        6: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        5: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        4: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        3: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        2: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        1: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
SystemStackError (stack level too deep)
```

### What was your diagnosis of the problem?

I think that it can be supposed that `sh_with_status` should be called rather than `sh_with_code` because Process::Status#exitstatus is called later on.
(related to #6036)

After this changes, the result of calling the method is as follows:

```
irb(main):011:0> load './lib/bundler/gem_helper.rb'
=> true
irb(main):012:0>
irb(main):013:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
=> ["bin\nbundler.gemspec\nCHANGELOG.md\nCODE_OF_CONDUCT.md\ndoc\nexe\nGemfile\nGemfile.lock\nlib\nLICENSE.md\nman\nRakefile\nREADME.md\nspec\ntask\n", 0]
```

I am not sure if I could remove the method since I cannot have confidence that the method is not used anymore. So I simply fixed it.
@colby-swandale colby-swandale added this to the 1.16.4 milestone Aug 15, 2018
@colby-swandale
Copy link
Member

@bundlerbot retry

@bundlerbot
Copy link
Collaborator

⌛ Testing commit 88ea68f with merge 45c7667...

bundlerbot added a commit that referenced this pull request Aug 15, 2018
Fix SystemStackError (stack level too deep) in GemHelper#sh_with_code

Hello. I found a method which raises SystemStackError by chance.

### What was the end-user problem that led to this PR?

The method always calls itself recursively like as follows:

```
irb(main):006:0> require './lib/bundler/gem_helper'
=> true
irb(main):007:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
Traceback (most recent call last):
       16: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       15: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       14: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       13: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       12: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       11: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
       10: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        9: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        8: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        7: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        6: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        5: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        4: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        3: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        2: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
        1: from /home/hibariya/src/github.com/bundler/bundler/lib/bundler/gem_helper.rb:191:in `sh_with_code'
SystemStackError (stack level too deep)
```

### What was your diagnosis of the problem?

I think that it can be supposed that `sh_with_status` should be called rather than `sh_with_code` because Process::Status#exitstatus is called later on.
(related to #6036)

After this changes, the result of calling the method is as follows:

```
irb(main):011:0> load './lib/bundler/gem_helper.rb'
=> true
irb(main):012:0>
irb(main):013:0> Bundler::GemHelper.new.send(:sh_with_code, 'ls')
=> ["bin\nbundler.gemspec\nCHANGELOG.md\nCODE_OF_CONDUCT.md\ndoc\nexe\nGemfile\nGemfile.lock\nlib\nLICENSE.md\nman\nRakefile\nREADME.md\nspec\ntask\n", 0]
```

I am not sure if I could remove the method since I cannot have confidence that the method is not used anymore. So I simply fixed it.
@bundlerbot
Copy link
Collaborator

☀️ Test successful - status-travis
Approved by: colby-swandale
Pushing 45c7667 to master...

@bundlerbot bundlerbot merged commit 88ea68f into rubygems:master Aug 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants