amirrajan / rubymotion-applied

RubyMotion documentation provided by the community. Submit a pull request to the docs for a free one year indie subscription.
Apache License 2.0
49 stars 10 forks source link

Backtrace line numbers are incorrect #129

Closed andrewhavens closed 4 years ago

andrewhavens commented 4 years ago

Using RubyMotion 6.1...there seems to be an issue with reporting the correct line numbers in backtraces. I have included a reproducible example.

Given the following class:

class LineNumberExample
  def trigger_error
    first_block_called do
      second_block_called do
        example_error
      end
    end
  end

  def first_block_called(&block)
    block.call
  end

  def second_block_called(&block)
    block.call
  end

  def example_error
    foobar
  end
end

And calling it from within the app:

example = LineNumberExample.new
example.trigger_error

Results in this error:

2019-07-22 15:05:15.875 MyApp[84987:20403768] *** Terminating app due to uncaught exception 'NameError', reason: 'app/lib/line_number_example.rb:24:in `example_error': undefined local variable or method `foobar' for #<LineNumberExample:0x60000267ae80> (NameError)
  from app/lib/line_number_example.rb:20:in `second_block_called'
  from app/lib/line_number_example.rb:14:in `block in trigger_error'
  from app/lib/line_number_example.rb:16:in `first_block_called'
  from app/lib/line_number_example.rb:13:in `trigger_error'
  from app/screens/example_screen.rb:105:in `run_test'
'
*** First throw call stack:
(
  0   CoreFoundation                      0x00000001044a86fb __exceptionPreprocess + 331
  1   libobjc.A.dylib                     0x00000001023d3ac5 objc_exception_throw + 48
  2   MyApp                      0x00000001011b89ec _ZL10__vm_raisev + 348
  3   MyApp                      0x00000001011b8a80 rb_vm_raise + 80
  4   MyApp                      0x00000001010c3539 rb_exc_raise + 9
  5   MyApp                      0x00000001011b68cb rb_vm_method_missing + 747
  6   MyApp                      0x000000010119ec57 rb_vm_dispatch + 7127
  7   MyApp                      0x000000010119cd42 rb_vm_trigger_method_missing + 834
  8   MyApp                      0x000000010119dcc1 rb_vm_dispatch + 3137
  9   MyApp                      0x0000000100c664d4 vm_dispatch + 1380
  10  MyApp                      0x0000000100c68859 rb_scope__example_error__ + 57
  11  MyApp                      0x000000010119eaa6 rb_vm_dispatch + 6694
  12  MyApp                      0x0000000100c664d4 vm_dispatch + 1380
  13  MyApp                      0x0000000100c686c1 rb_scope__trigger_error__block__.1 + 65
  14  MyApp                      0x00000001011a08d9 _ZL13vm_block_evalP7RoxorVMP11rb_vm_blockP13objc_selectormiPKm + 1529
  15  MyApp                      0x000000010119ec57 rb_vm_dispatch + 7127
  16  MyApp                      0x0000000100c664d4 vm_dispatch + 1380
  17  MyApp                      0x0000000100c687e0 rb_scope__second_block_called__ + 80
  18  MyApp                      0x000000010119eaa6 rb_vm_dispatch + 6694
  19  MyApp                      0x0000000100c664d4 vm_dispatch + 1380
  20  MyApp                      0x0000000100c68646 rb_scope__trigger_error__block__ + 118
  21  MyApp                      0x00000001011a08d9 _ZL13vm_block_evalP7RoxorVMP11rb_vm_blockP13objc_selectormiPKm + 1529
  22  MyApp                      0x000000010119ec57 rb_vm_dispatch + 7127
  23  MyApp                      0x0000000100c664d4 vm_dispatch + 1380
  24  MyApp                      0x0000000100c68750 rb_scope__first_block_called__ + 80
  25  MyApp                      0x000000010119eaa6 rb_vm_dispatch + 6694
  26  MyApp                      0x0000000100c664d4 vm_dispatch + 1380
  27  MyApp                      0x0000000100c6859e rb_scope__trigger_error__ + 110
  28  MyApp                      0x000000010119eaa6 rb_vm_dispatch + 6694
  29  MyApp                      0x0000000100c78464 vm_dispatch + 1380
  30  MyApp                      0x0000000100c7fb81 rb_scope__run_test__ + 1201
  31  MyApp                      0x0000000100c7fbbd __unnamed_39 + 13
amirrajan commented 4 years ago

Noted. I'll verify.

amirrajan commented 4 years ago

How about with the 6.2 release?

andrewhavens commented 4 years ago

Tried it again in 6.4 and it looks like this issue has been resolved.