Project

General

Profile

Actions

Bug #5330

closed

Bug Report: wrong backtrace

Added by ulrich (Ulrich Kramer) over 12 years ago. Updated almost 10 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
Backport:
[ruby-core:39572]

Description

=begin
I would like to report a ruby1.9 bug. I tried to create a new ticket in redmine. After registration(wonderix) I tried to login, but I didn't succeed. After 4 password resets I gave up.

So here is my description:

a.rb:
test = Class.new(Object)
test.class_eval(File.read("b.rb"),"b.rb",1)
test.run

b.rb:
p caller
def self.run()
p caller
end

When I run a.rb I got:
["a.rb:2:in class_eval'", "a.rb:2:in '"]
["a.rb:3:in `'"]

Should be:
["b.rb:1:in class_eval'", "a.rb:2:in '"]
["b.rb:3:in `'"]

ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

Mit freundlichen Grüßen | best regards,

Ulrich Kramer
Senior Developer
=end

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

  • ruby -v changed from - to ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
Actions #2

Updated by ko1 (Koichi Sasada) about 12 years ago

  • Assignee set to akr (Akira Tanaka)
Actions #3

Updated by shyouhei (Shyouhei Urabe) about 12 years ago

  • Status changed from Open to Assigned

Updated by akr (Akira Tanaka) almost 10 years ago

  • Status changed from Assigned to Rejected

Ulrich Kramer wrote:

a.rb:
test = Class.new(Object)
test.class_eval(File.read("b.rb"),"b.rb",1)
test.run

b.rb:
p caller
def self.run()
p caller
end

When I run a.rb I got:
["a.rb:2:in class_eval'", "a.rb:2:in '"]
["a.rb:3:in `'"]

Should be:
["b.rb:1:in class_eval'", "a.rb:2:in '"]
["b.rb:3:in `'"]

No.

caller() doesn't return the current stack frame unless 0 is specified as the argument.

caller() returns an array which contains the caller stack frame and ancestor stack frames.
caller of the top level of b.rb is test.class_eval described in a.rb.
caller of "run" method is the top level of a.rb.

caller(0) makes things clear.

% cat a.rb
test = Class.new(Object)
test.class_eval(File.read("b.rb"),"b.rb",1)
test.run
% cat b.rb
p caller(0)
def self.run()
  p caller(0)
end
% ./ruby a.rb                               
["b.rb:1:in `<main>'", "a.rb:2:in `class_eval'", "a.rb:2:in `<main>'"]
["b.rb:3:in `run'", "a.rb:3:in `<main>'"]

b.rb:1 and b.rb:3 appears as the first element (current stack frame).
The second element shows the stack frame in a.rb.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0