Forum: Ruby-core [ruby-trunk - Feature #7434][Open] Allow caller_locations and backtrace_locations to receive negativ

Posted by sam.saffron (Sam Saffron) (Guest)
on 2012-11-25 23:00
(Received via mailing list)
Issue #7434 has been reported by sam.saffron (Sam Saffron).

----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434

Author: sam.saffron (Sam Saffron)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by sam.saffron (Sam Saffron) (Guest)
on 2012-11-25 23:10
(Received via mailing list)
Issue #7434 has been updated by sam.saffron (Sam Saffron).


ouch, this was meant to be pointed at 2.0 can't figure out how to change
----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-33877

Author: sam.saffron (Sam Saffron)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by zzak (Zachary Scott) (Guest)
on 2012-11-25 23:52
(Received via mailing list)
Issue #7434 has been updated by zzak (Zachary Scott).

Category set to core
Status changed from Open to Assigned
Assignee set to ko1 (Koichi Sasada)
Target version set to 2.0.0


----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-33883

Author: sam.saffron (Sam Saffron)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 2.0.0


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by zzak (Zachary Scott) (Guest)
on 2012-11-25 23:55
(Received via mailing list)
Issue #7434 has been updated by zzak (Zachary Scott).

Target version changed from 2.0.0 to next minor


----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-33885

Author: sam.saffron (Sam Saffron)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: next minor


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by SASADA Koichi (Guest)
on 2012-11-26 00:57
(Received via mailing list)
(2012/11/26 6:59), sam.saffron (Sam Saffron) wrote:
> caller_locations(0,-2) # should strip the bottom frame

2nd parmeter specify `how many frames'.
I feel 1st parameter is nice to accept negative index.

I don't have positive and negative one.

Could you show the concrete example and performance issue?
Posted by sam.saffron (Sam Saffron) (Guest)
on 2012-11-26 23:36
(Received via mailing list)
Issue #7434 has been updated by sam.saffron (Sam Saffron).


This is a "typical" caller trace for a rails app:


app/controllers/list_controller.rb:8:in `block (2 levels) in 
<class:ListController>'
actionpack (3.2.9) lib/action_controller/metal/implicit_render.rb:4:in 
`send_action'
actionpack (3.2.9) lib/abstract_controller/base.rb:167:in 
`process_action'
actionpack (3.2.9) lib/action_controller/metal/rendering.rb:10:in 
`process_action'
actionpack (3.2.9) lib/abstract_controller/callbacks.rb:18:in `block in 
process_action'
activesupport (3.2.9) lib/active_support/callbacks.rb:447:in 
`_run__315638444__process_action__306812856__callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in 
`__run_callback'
activesupport (3.2.9) lib/active_support/callbacks.rb:385:in 
`_run_process_action_callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:81:in 
`run_callbacks'
actionpack (3.2.9) lib/abstract_controller/callbacks.rb:17:in 
`process_action'
actionpack (3.2.9) lib/action_controller/metal/rescue.rb:29:in 
`process_action'
actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:30:in 
`block in process_action'
activesupport (3.2.9) lib/active_support/notifications.rb:123:in `block 
in instrument'
activesupport (3.2.9) 
lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.9) lib/active_support/notifications.rb:123:in 
`instrument'
actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:29:in 
`process_action'
actionpack (3.2.9) lib/action_controller/metal/params_wrapper.rb:207:in 
`process_action'
activerecord (3.2.9) 
lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.9) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.9) lib/abstract_controller/rendering.rb:45:in `process'
/home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/MiniProfiler-cf359967ec7b/Ruby/lib/mini_profiler/profiling_methods.rb:90:in 
`block in profile_method'
actionpack (3.2.9) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.9) lib/action_controller/metal/rack_delegation.rb:14:in 
`dispatch'
actionpack (3.2.9) lib/action_controller/metal.rb:246:in `block in 
action'
actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:73:in 
`dispatch'
actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:601:in 
`call'
vendor/gems/message_bus/lib/message_bus/rack/middleware.rb:42:in `call'
sass (3.2.3) lib/sass/plugin/rack.rb:54:in `call'
actionpack (3.2.9) 
lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/params_parser.rb:21:in 
`call'
actionpack (3.2.9) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/cookies.rb:341:in 
`call'
activerecord (3.2.9) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.9) 
lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in 
`call'
actionpack (3.2.9) lib/action_dispatch/middleware/callbacks.rb:28:in 
`block in call'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in 
`_run__769637742__call__1054697050__callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in 
`__run_callback'
activesupport (3.2.9) lib/active_support/callbacks.rb:385:in 
`_run_call_callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:81:in 
`run_callbacks'
actionpack (3.2.9) lib/action_dispatch/middleware/callbacks.rb:27:in 
`call'
actionpack (3.2.9) lib/action_dispatch/middleware/reloader.rb:65:in 
`call'
actionpack (3.2.9) lib/action_dispatch/middleware/remote_ip.rb:31:in 
`call'
actionpack (3.2.9) 
lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.9) 
lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.9) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.9) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.9) lib/active_support/tagged_logging.rb:22:in 
`tagged'
railties (3.2.9) lib/rails/rack/logger.rb:16:in `call'
config/initializers/quiet_logger.rb:10:in `call_with_quiet_assets'
config/initializers/silence_logger.rb:19:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/request_id.rb:22:in 
`call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.9) 
lib/active_support/cache/strategy/local_cache.rb:72:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/static.rb:62:in `call'
airbrake (3.1.2) lib/airbrake/rack.rb:42:in `call'
airbrake (3.1.2) lib/airbrake/user_informer.rb:12:in `call'
/home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/MiniProfiler-cf359967ec7b/Ruby/lib/mini_profiler/profiler.rb:310:in 
`call'
railties (3.2.9) lib/rails/engine.rb:479:in `call'
railties (3.2.9) lib/rails/application.rb:223:in `call'
railties (3.2.9) lib/rails/railtie/configurable.rb:30:in 
`method_missing'
thin (1.5.0) lib/thin/connection.rb:81:in `block in pre_process'
thin (1.5.0) lib/thin/connection.rb:79:in `catch'
thin (1.5.0) lib/thin/connection.rb:79:in `pre_process'
thin (1.5.0) lib/thin/connection.rb:54:in `process'
/home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/thin-em-websocket-5aa856511441/lib/thin-em-websocket.rb:258:in 
`process'
thin (1.5.0) lib/thin/connection.rb:39:in `receive_data'
/home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/thin-em-websocket-5aa856511441/lib/thin-em-websocket.rb:269:in 
`receive_data'
eventmachine (1.0.0) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.0) lib/eventmachine.rb:187:in `run'
thin (1.5.0) lib/thin/backends/base.rb:63:in `start'
thin (1.5.0) lib/thin/server.rb:159:in `start'
thin (1.5.0) lib/thin/controllers/controller.rb:86:in `start'
thin (1.5.0) lib/thin/runner.rb:187:in `run_command'
thin (1.5.0) lib/thin/runner.rb:152:in `run!'
thin (1.5.0) bin/thin:6:in `<top (required)>'
/home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bin/thin:19:in `load'
/home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bin/thin:19:in `<main>'
/home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bin/ruby_noexec_wrapper:14:in 
`eval'
/home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bin/ruby_noexec_wrapper:14:in 
`<main>'


This means that there are 60 or so frames below my application. If I 
just want to gather a trace for my application code, I really want:

caller_locations(0, -60) ... I work around by doing 
caller_locations[0..-60] however the VM is going to do tons of work to 
grab all these objects just for me to discard them.
----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-33985

Author: sam.saffron (Sam Saffron)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: next minor


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by sam.saffron (Sam Saffron) (Guest)
on 2012-11-26 23:38
(Received via mailing list)
Issue #7434 has been updated by sam.saffron (Sam Saffron).


This means, I don't really know how many frames I want to take, I just 
know how many frames I want to discard.
----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-33986

Author: sam.saffron (Sam Saffron)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: next minor


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by SASADA Koichi (Guest)
on 2012-11-27 00:38
(Received via mailing list)
(2012/11/27 7:35), sam.saffron (Sam Saffron) wrote:
> This means that there are 60 or so frames below my application. If I just want 
to gather a trace for my application code, I really want:
>
> caller_locations(0, -60) ... I work around by doing caller_locations[0..-60] 
however the VM is going to do tons of work to grab all these objects just for me 
to discard them.

I know that Rails (and framework) has big backtrace array.

My question is: use-case of negative number for performance.
Your answer only shows "backtrace is big".

By the way, current implementation grabs *all* of backtrace information
and cuts `n'th elements from `level' (`n' is 2nd argument and `level' is
1st argument).  This is implementation limitation.  We need to seek all
of backtrace to make correct backtrace. If you want to know "why it is
needed?", please read source code. Short answer is "There are some
frames which does not have location information".
Posted by sam.saffron (Sam Saffron) (Guest)
on 2012-11-27 07:52
(Received via mailing list)
Issue #7434 has been updated by sam.saffron (Sam Saffron).


> My question is: use-case of negative number for performance. Your answer only 
shows "backtrace is big".

Apologies, well for MiniProfiler ( 
https://github.com/SamSaffron/MiniProfiler/tree/master/Ruby ) we gather 
stack traces quite aggressively, every time a query is execute a 
backtrace is materialized.

A classic place of where I would like to cut down on backtrace overhead 
is the sampling profiler see: 
https://github.com/SamSaffron/MiniProfiler/blob/ma...

Another use case would be a user option for :application_trace_only, 
that would figure out how many frames to skip in the first SQL 
interception and store that on the Thread so following calls to grab 
stack traces only include the "application" section and the framework 
stuff is not gathered.

The seek is still cheaper than materializing all the strings for the 
filenames and so on just to discard.


----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-34014

Author: sam.saffron (Sam Saffron)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: next minor


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by SASADA Koichi (Guest)
on 2012-11-27 09:23
(Received via mailing list)
(2012/11/27 15:52), sam.saffron (Sam Saffron) wrote:
> Issue #7434 has been updated by sam.saffron (Sam Saffron).
>
>
>> My question is: use-case of negative number for performance. Your answer only 
shows "backtrace is big".
>
> Apologies, well for MiniProfiler ( 
https://github.com/SamSaffron/MiniProfiler/tree/master/Ruby ) we gather stack 
traces quite aggressively, every time a query is execute a backtrace is 
materialized.
>
> A classic place of where I would like to cut down on backtrace overhead is the 
sampling profiler see: 
https://github.com/SamSaffron/MiniProfiler/blob/ma...

I think you need to grab all of stack each time.
I'm not sure the negative number is good for this reason.

> Another use case would be a user option for :application_trace_only, that would 
figure out how many frames to skip in the first SQL interception and store that on 
the Thread so following calls to grab stack traces only include the "application" 
section and the framework stuff is not gathered.

You need to grab all of stack trace to check which is skipped frame or
not.  Please correct my if my understanding is wrong.

I also am not sure why negative number is needed for this purpose.


----

Ah, I understand your purpose. I can't understand how to use negative
number.

But I understand now.

[top of stack frame]
caller
foo4
foo3
foo2
foo1
f/w3 # f/w = framework
f/w2
f/w1
main
[bottom of stack frame]

In this case, framework consumes 3 frames and you only want to know
stack frame only "all of frame size - framework frame size (=3)".

I missed the point that framework knows how many frames consumed (in
this case: 3).

2nd argument is "how many frames from top".

So your suggestion.
(2nd argument) `n' means:
  if n > 0
    how many frames from top of frame
  elsif n <= 0
    how many frames should *eliminate* from bottom of frame
  end


I feel it makes sense.

The last point is API design.
"negative number" to this purpose is feasible?
Any other example for other methods?
Posted by sam.saffron (Sam Saffron) (Guest)
on 2012-11-27 10:35
(Received via mailing list)
Issue #7434 has been updated by sam.saffron (Sam Saffron).


>  The last point is API design.
> "negative number" to this purpose is feasible?

I like negative numbers cause it has some parity with the range APIs, 
eg: [1,2,3][0..-2] # skip last

> Any other example for other methods?

I can not think of a use case for for the first param being negative, 
even though for arrays [1,2,3](-2..-1) makes sense, I can not think of a 
case where one would do caller_locations(-10, -1), the proposal is all 
about making the second param more flexible.
----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-34022

Author: sam.saffron (Sam Saffron)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: next minor


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by SASADA Koichi (Guest)
on 2012-11-27 10:56
(Received via mailing list)
(2012/11/27 18:35), sam.saffron (Sam Saffron) wrote:
>> >  The last point is API design.
>> > "negative number" to this purpose is feasible?
> I like negative numbers cause it has some parity with the range APIs, eg: 
[1,2,3][0..-2] # skip last

I agree that it is similar to the negative end of range.
However, range points *position* (index), not a size.

I think similar, but different concept cause confusion.

Ideas:

(1) Accept your idea.
    Define new concept.
   (Do not refer Array#[])

(2) Introduce 3rd argument to specify eliminate
    I feel it is bad.

(3) Consider argument

  (3-1) Accept Range object on 1st parameter
    caller(2..-2) #=> [foo2, ..., f/w2] on [ruby-core:50208] example.

  (3-2) ... no idea


(3-1) seems good?  It is same concept of Array#[].  Easy to explain.


>> > Any other example for other methods?
> I can not think of a use case for for the first param being negative, even 
though for arrays [1,2,3](-2..-1) makes sense, I can not think of a case where one 
would do caller_locations(-10, -1), the proposal is all about making the second 
param more flexible.

I want to know other similar methods we can mimic.
Posted by sam.saffron (Sam Saffron) (Guest)
on 2012-11-27 22:09
(Received via mailing list)
Issue #7434 has been updated by sam.saffron (Sam Saffron).


I think either 1) or 3-1), works ok.

Though there is an issue with accepting ranges: caller(1..-6, 8) becomes 
a bit weird cause you are defining the length in two spots.

I can not find any other place with a similar api, anyone else?
----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-34057

Author: sam.saffron (Sam Saffron)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: next minor


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by SASADA Koichi (Guest)
on 2012-11-28 20:50
(Received via mailing list)
(2012/11/28 6:08), sam.saffron (Sam Saffron) wrote:
> Though there is an issue with accepting ranges: caller(1..-6, 8) becomes a bit 
weird cause you are defining the length in two spots.

It should be error.

See:

[][0..1, 2]
#=>
t.rb:1:in `[]': can't convert Range into Integer (TypeError)
  from t.rb:1:in `<main>'
Posted by SASADA Koichi (Guest)
on 2012-11-29 01:28
(Received via mailing list)
(2012/11/28 6:08), sam.saffron (Sam Saffron) wrote:
> I think either 1) or 3-1), works ok.

I committed (3-1).

Could you check it?
Also I'm very happy if you write tests for it.
Posted by sam.saffron (Sam Saffron) (Guest)
on 2012-11-30 02:27
(Received via mailing list)
Issue #7434 has been updated by sam.saffron (Sam Saffron).


@ko1 will try to write some tests next week.

On first go I got a segfault:

(pry):1: [BUG] backtrace_collect: unreachable
ruby 2.0.0dev (2012-11-30) [i686-linux]

-- Control frame information 
-----------------------------------------------
c:0024 p:---- s:0096 e:000095 CFUNC  :caller_locations
c:0023 p:0009 s:0091 e:000090 EVAL   (pry):1 [FINISH]
c:0022 p:---- s:0089 e:000088 CFUNC  :eval
c:0021 p:0089 s:0083 e:000082 METHOD 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:275
c:0020 p:0037 s:0076 e:000075 METHOD 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:251
c:0019 p:0012 s:0071 e:000070 BLOCK 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:231 
[FINISH]
c:0018 p:---- s:0069 e:000068 CFUNC  :loop
c:0017 p:0007 s:0066 e:000065 BLOCK 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:232 
[FINISH]
c:0016 p:---- s:0064 e:000063 CFUNC  :catch
c:0015 p:0009 s:0060 e:000059 BLOCK 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:229 
[FINISH]
c:0014 p:---- s:0058 e:000057 CFUNC  :catch
c:0013 p:0051 s:0054 e:000053 METHOD 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:228
c:0012 p:0192 s:0048 e:000047 METHOD 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_class.rb:154
c:0011 p:0204 s:0041 e:000040 BLOCK 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/cli.rb:171 
[FINISH]
c:0010 p:---- s:0035 e:000034 CFUNC  :call
c:0009 p:0012 s:0031 e:000030 BLOCK 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/cli.rb:65 [FINISH]
c:0008 p:---- s:0028 e:000027 CFUNC  :each
c:0007 p:0087 s:0025 e:000024 METHOD 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/cli.rb:65
c:0006 p:0030 s:0020 e:000019 TOP 
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/bin/pry:16 [FINISH]
c:0005 p:---- s:0018 e:000017 CFUNC  :load
c:0004 p:0099 s:0014 e:001ac8 EVAL 
/home/sam/.rvm/gems/ruby-head/bin/pry:19 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC  :eval
c:0002 p:0077 s:0005 e:0019a8 EVAL 
/home/sam/.rvm/gems/ruby-head/bin/ruby_noexec_wrapper:14 [FINISH]
c:0001 p:0000 s:0002 e:000574 TOP    [FINISH]

/home/sam/.rvm/gems/ruby-head/bin/ruby_noexec_wrapper:14:in `<main>'
/home/sam/.rvm/gems/ruby-head/bin/ruby_noexec_wrapper:14:in `eval'
/home/sam/.rvm/gems/ruby-head/bin/pry:19:in `<main>'
/home/sam/.rvm/gems/ruby-head/bin/pry:19:in `load'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/bin/pry:16:in `<top 
(required)>'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/cli.rb:65:in 
`parse_options'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/cli.rb:65:in 
`each'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/cli.rb:65:in 
`block in parse_options'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/cli.rb:65:in 
`call'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/cli.rb:171:in 
`block in <top (required)>'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_class.rb:154:in 
`start'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:228:in 
`repl'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:228:in 
`catch'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:229:in 
`block in repl'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:229:in 
`catch'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:232:in 
`block (2 levels) in repl'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:232:in 
`loop'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:231:in 
`block (3 levels) in repl'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:251:in 
`rep'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:275:in 
`re'
/home/sam/.rvm/gems/ruby-head/gems/pry-0.9.10/lib/pry/pry_instance.rb:275:in 
`eval'
(pry):1:in `__pry__'
(pry):1:in `caller_locations'

-- C level backtrace information 
-------------------------------------------
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1ab92c) 
[0xb76d492c] vm_dump.c:646
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x5ad3d) 
[0xb7583d3d] error.c:306
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(rb_bug+0x40) 
[0xb7584d40] error.c:325
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1ace51) 
[0xb76d5e51] vm_backtrace.c:478
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1ace9f) 
[0xb76d5e9f] vm_backtrace.c:840
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19301e) 
[0xb76bc01e] vm_insnhelper.c:1318
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1964df) 
[0xb76bf4df] vm_insnhelper.c:1462
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a3d77) 
[0xb76ccd77] vm_insnhelper.c:1552
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19a330) 
[0xb76c3330] insns.def:1003
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19f757) 
[0xb76c8757] vm.c:1156
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19fdbe) 
[0xb76c8dbe] vm_eval.c:1208
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a02b9) 
[0xb76c92b9] vm_eval.c:1249
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x6890f) 
[0xb759190f] proc.c:382
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19301e) 
[0xb76bc01e] vm_insnhelper.c:1318
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1964df) 
[0xb76bf4df] vm_insnhelper.c:1462
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a3d77) 
[0xb76ccd77] vm_insnhelper.c:1552
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19a91a) 
[0xb76c391a] insns.def:1018
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19f757) 
[0xb76c8757] vm.c:1156
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a4a49) 
[0xb76cda49] vm.c:627
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(rb_rescue2+0x173) 
[0xb758c8b3] eval.c:714
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x195442) 
[0xb76be442] vm_eval.c:981
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19303e) 
[0xb76bc03e] vm_insnhelper.c:1324
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1964df) 
[0xb76bf4df] vm_insnhelper.c:1462
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a3d77) 
[0xb76ccd77] vm_insnhelper.c:1552
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19a330) 
[0xb76c3330] insns.def:1003
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19f757) 
[0xb76c8757] vm.c:1156
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a538d) 
[0xb76ce38d] vm.c:627
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(rb_catch_obj+0xc9) 
[0xb76c0fc9] vm_eval.c:1766
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x198097) 
[0xb76c1097] vm_eval.c:1742
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19301e) 
[0xb76bc01e] vm_insnhelper.c:1318
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1964df) 
[0xb76bf4df] vm_insnhelper.c:1462
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a3d77) 
[0xb76ccd77] vm_insnhelper.c:1552
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19a330) 
[0xb76c3330] insns.def:1003
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19f757) 
[0xb76c8757] vm.c:1156
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a538d) 
[0xb76ce38d] vm.c:627
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(rb_catch_obj+0xc9) 
[0xb76c0fc9] vm_eval.c:1766
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x198097) 
[0xb76c1097] vm_eval.c:1742
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19301e) 
[0xb76bc01e] vm_insnhelper.c:1318
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1964df) 
[0xb76bf4df] vm_insnhelper.c:1462
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a3d77) 
[0xb76ccd77] vm_insnhelper.c:1552
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19a330) 
[0xb76c3330] insns.def:1003
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19f757) 
[0xb76c8757] vm.c:1156
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a06a6) 
[0xb76c96a6] vm.c:627
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x6ac1d) 
[0xb7593c1d] proc.c:566
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19301e) 
[0xb76bc01e] vm_insnhelper.c:1318
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1964df) 
[0xb76bf4df] vm_insnhelper.c:1462
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a3d77) 
[0xb76ccd77] vm_insnhelper.c:1552
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19a91a) 
[0xb76c391a] insns.def:1018
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19f757) 
[0xb76c8757] vm.c:1156
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(rb_yield+0x173) 
[0xb76ce9f3] vm.c:627
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(rb_ary_each+0x54) 
[0xb754a144] array.c:1677
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19303e) 
[0xb76bc03e] vm_insnhelper.c:1324
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1964df) 
[0xb76bf4df] vm_insnhelper.c:1462
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a3d77) 
[0xb76ccd77] vm_insnhelper.c:1552
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19a330) 
[0xb76c3330] insns.def:1003
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19f757) 
[0xb76c8757] vm.c:1156
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(rb_iseq_eval+0x109) 
[0xb76cece9] vm.c:1391
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x663ee) 
[0xb758f3ee] load.c:557
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x66cba) 
[0xb758fcba] load.c:639
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19301e) 
[0xb76bc01e] vm_insnhelper.c:1318
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1964df) 
[0xb76bf4df] vm_insnhelper.c:1462
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a3d77) 
[0xb76ccd77] vm_insnhelper.c:1552
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19a330) 
[0xb76c3330] insns.def:1003
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19f757) 
[0xb76c8757] vm.c:1156
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19fdbe) 
[0xb76c8dbe] vm_eval.c:1208
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a02b9) 
[0xb76c92b9] vm_eval.c:1249
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19301e) 
[0xb76bc01e] vm_insnhelper.c:1318
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1964df) 
[0xb76bf4df] vm_insnhelper.c:1462
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x1a3d77) 
[0xb76ccd77] vm_insnhelper.c:1552
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19a330) 
[0xb76c3330] insns.def:1003
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x19f757) 
[0xb76c8757] vm.c:1156
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(rb_iseq_eval_main+0x15d) 
[0xb76ceead] vm.c:1404
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(+0x61e3c) 
[0xb758ae3c] eval.c:250
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(ruby_exec_node+0x24) 
[0xb758c2a4] eval.c:315
/home/sam/.rvm/rubies/ruby-head/lib/libruby.so.2.0(ruby_run_node+0x36) 
[0xb758e236] eval.c:307
pry() [0x8048698]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0xb73804d3]
pry() [0x80486c1]

----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-34170

Author: sam.saffron (Sam Saffron)
Status: Closed
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: next minor


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by SASADA Koichi (Guest)
on 2012-11-30 05:44
(Received via mailing list)
(2012/11/30 10:25), sam.saffron (Sam Saffron) wrote:
> @ko1 will try to write some tests next week.

Thank you so much.

> On first go I got a segfault:

Cool!
Reproduce code?
Posted by sam.saffron (Sam Saffron) (Guest)
on 2012-12-03 03:00
(Received via mailing list)
Issue #7434 has been updated by sam.saffron (Sam Saffron).


Getting it on a clean rvm install of ruby-head with

test.rb
caller_location(0,-1)

I hope my compile is correct, other stuff seems to work fine
----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-34332

Author: sam.saffron (Sam Saffron)
Status: Closed
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: next minor


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Posted by SASADA Koichi (Guest)
on 2012-12-03 08:20
(Received via mailing list)
(2012/12/03 11:00), sam.saffron (Sam Saffron) wrote:
> Getting it on a clean rvm install of ruby-head with
>
> test.rb
> caller_location(0,-1)

reproduced!! thanks.
Posted by zzak (Zachary Scott) (Guest)
on 2012-12-31 05:05
(Received via mailing list)
Issue #7434 has been updated by zzak (Zachary Scott).

Status changed from Closed to Assigned

I have committed a test for range argument in r38664, please check it.
----------------------------------------
Feature #7434: Allow caller_locations and backtrace_locations to receive 
negative params
https://bugs.ruby-lang.org/issues/7434#change-35164

Author: sam.saffron (Sam Saffron)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: next minor


Further to http://bugs.ruby-lang.org/issues/7051

It would be nice if caller_locations and backtrace_locations has some 
parity with range apis.

pry(main)> [1,2,3][0..-2]
=> [1, 2]

Similarly:

caller_locations(0,-2) # should strip the bottom frame

This is actually quite important for diagnostics of Rails and other 
frameworks where the app code starts at a very deep frame.

At the moment you are forced to materialize all frames just to discard.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.