Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle evaled source code #10

Closed
wants to merge 1 commit into from

Conversation

casperisfine
Copy link
Contributor

Fixes the issue reported here: https://bugs.ruby-lang.org/issues/17863#note-1

Otherwise it would fail with:

No such file or directory @ rb_sysopen - eval (Errno::ENOENT)

I could explictly check for "eval" but I think it's better to handle all potential file system issues, because eval interfaces allow to provide arbitrary paths.

cc @ko1

Otherwise it would fail with:

```
No such file or directory @ rb_sysopen - eval (Errno::ENOENT)
```

I could explictly check for `"eval"` but I think it's
better to handle all potential file system issues.
@ko1
Copy link
Collaborator

ko1 commented May 17, 2021

Thank you for the report.

I'm not sure how to reproduce it. Maybe it is related to the eval, but I couldn't reproduce the error with step-in into eval-source code and binding.bp. Could you share the small repro-code?

@casperisfine
Copy link
Contributor Author

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem "debug", "1.0.0.beta3"
end

module Foo
  module_eval <<~RUBY, '--eval--', 1
    def self.bar
      binding.bp
    end
  RUBY
end

Foo.bar
#<Thread:0x00007fc65f04d5f8 /Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/session.rb:78 run> terminated with exception (report_on_exception is true):
/Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/source_repository.rb:13:in `read': No such file or directory @ rb_sysopen - --eval-- (Errno::ENOENT)
	from /Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/source_repository.rb:13:in `add'
	from /Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/session.rb:825:in `on_load'
	from /Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/session.rb:88:in `block in initialize'
["/Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/thread_client.rb",
 599,
 #<Errno::ENOENT: No such file or directory @ rb_sysopen - --eval-->,
 ["/Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/source_repository.rb:13:in `read'",
  "/Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/source_repository.rb:13:in `add'",
  "/Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/session.rb:825:in `on_load'",
  "/Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/session.rb:88:in `block in initialize'"]]
/Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/source_repository.rb:13:in `read': No such file or directory @ rb_sysopen - --eval-- (Errno::ENOENT)
	from /Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/source_repository.rb:13:in `add'
	from /Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/session.rb:825:in `on_load'
	from /Users/byroot/.gem/ruby/3.0.1/gems/debug-1.0.0.beta3/lib/debug/session.rb:88:in `block in initialize'

ko1 added a commit that referenced this pull request May 17, 2021
`eval` can specify unexisting file so it shouldn't read.
Without `eval` the file can be removed just after compiling,
the error should not be propagated.
If given file is existing file for eval context, it should not
override the source code.

The issue is pointed at #10 by
casperisfine and this patc contains a part of his patch.
@ko1 ko1 closed this May 17, 2021
@ko1
Copy link
Collaborator

ko1 commented May 17, 2021

Thank you, I could reproduce and I solved with other patch.

@casperisfine casperisfine deleted the handle-evaled-code branch May 17, 2021 08:42
ono-max referenced this pull request in ono-max/debug May 23, 2021
Show more pretty backtrace like:

```
(rdbg) bt
=>#0    block{|i=0, j=nil|} (3 levels) in foo at ~/src/rb/target.rb:12
  #1    [C] Integer#times at ~/src/rb/target.rb:11
  #2    rescue in rescue in block (2 levels) in foo at ~/src/rb/target.rb:11
  #3    rescue in block (2 levels) in foo at ~/src/rb/target.rb:8
  #4    block (2 levels) in foo at ~/src/rb/target.rb:5
  #5    [C] Integer#times at ~/src/rb/target.rb:4
  #6    block{|e=2|} in foo at ~/src/rb/target.rb:4
  #7    [C] Range#each at ~/src/rb/target.rb:3
  #8    [C] Enumerable#map at ~/src/rb/target.rb:3
  #9    Object#foo(a=3) at ~/src/rb/target.rb:3
  #10   <main> at ~/src/rb/target.rb:20
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants