banister / binding_of_caller Goto Github PK
View Code? Open in Web Editor NEWRetrieve the binding of a method's caller in MRI 1.9.2+
License: Other
Retrieve the binding of a method's caller in MRI 1.9.2+
License: Other
There is no spec for this case, currently.
Since I don't know specifically the behaviour, and it is not obvious (at least for me), we should add a test for that.
Hello,
I was running the test cases and I realized there is no "require 'bacon'" anywhere. I recommend adding a test_helper.rb file like this and doing a require 'bacon'
in there (among other things).
Thanks.
For better_errors
and web-console
we monkey-patch Exception, so we can get the binding in which it originated. This currently works fine for MRI as it calls Exception#set_backtrace
on every raise. it has a drawback, however.
If Binding#of_caller
throws an exception MRI 1.9.3 and 2.0 go into a stack overflow, (Exception#set_backtrace
is getting called and it raises again, etc) and 2.1.2 is segfaulting. See https://bugs.ruby-lang.org/issues/10164 for more details. MRI 2.1.2 will segfault if any Exception
is generated during Exception#set_backtrace
.
Checkout the following snippet:
class Exception
# The binding in which the exception originated in.
attr_reader :binding
# MRI calls `set_backtrace` every time it raises an exception. Overriding it
# to assign the `Exception#binding` every time you raise it.
def set_backtrace_with_binding_of_caller(*args)
# Thanks to @charliesome who wrote this bit for better_errors.
unless Thread.current[:__web_console_exception_lock]
Thread.current[:__web_console_exception_lock] = true
begin
# Raising an exception here will cause all of the rubies to go into a
# stack overflow. Some rubies may even segfault. See
# https://bugs.ruby-lang.org/issues/10164.
@binding = ::Kernel.binding.of_caller(1)
ensure
Thread.current[:__web_console_exception_lock] = false
end
end
set_backtrace_without_binding_of_caller(*args)
end
alias_method_chain :set_backtrace, :binding_of_caller
end
If @binding = ::Kernel.binding.of_caller(1)
raises I'm screwed. I see a couple of places where Binding#of_caller
can do so. Do you guys think its a good idea to just return nil
on those places? It can save us a segfault for 2.1.2 and possible future regressions in this kind of situations.
Raising errors while raising errors seems to be tricky to handle :)
Right now when rescuing into debuggers we have to do binding.of_caller(n) which could confuse the user as to what we are exactly doing if they don't know about binding_of_caller. It would be nice to imply what we are doing by having binding.caller_of_caller so the user could see that hey we are putting them into the context of the caller so they can debug the area that had an exception.
There is another small tidbit (but we can address that ourselves with an internal function) which is detecting if the caller is inside of a rescue and if it is push it to the next caller -- but I don't know much about ruby internals to say if that's easy to implement.
I've installed the gem and get the "Source is not available" message in the right pane when using with better_errors. Is there any additional configuration needed to see the code?
Hi, I'm trying to switch a Rails 4.1.6 app from MRI 2.1.3 to Rubinius 2.2.10 but I get an exception in combination with better_errors 2.0.0:
NoMethodError - undefined method `caller_locations' on an instance of ActionController::RoutingError.:
kernel/delta/kernel.rb:78:in `caller_locations (method_missing)'
better_errors (2.0.0) lib/better_errors/exception_extension.rb:6:in `set_backtrace'
kernel/common/exception.rb:139:in `set_context'
kernel/delta/kernel.rb:25:in `raise'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:71:in `controller'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:46:in `call'
actionpack (4.1.6) lib/action_dispatch/journey/router.rb:73:in `call'
kernel/bootstrap/array.rb:76:in `each'
actionpack (4.1.6) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:678:in `call'
bullet (4.13.2) lib/bullet/rack.rb:12:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
remotipart (1.2.1) lib/remotipart/middleware.rb:27:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.6) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:29:in `call'
activesupport (4.1.6) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
airbrake (4.1.0) lib/airbrake/rails/middleware.rb:13:in `call'
better_errors (2.0.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.0.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.0.0) lib/better_errors/middleware.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.6) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.6) lib/rails/rack/logger.rb:20:in `call'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.6) lib/rails/rack/logger.rb:20:in `call_without_quiet_assets (call)'
quiet_assets (1.0.3) lib/quiet_assets.rb:23:in `call (call_with_quiet_assets)'
actionpack (4.1.6) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
rack-mini-profiler (0.9.2) lib/mini_profiler/profiler.rb:300:in `call'
airbrake (4.1.0) lib/airbrake/user_informer.rb:16:in `_call'
airbrake (4.1.0) lib/airbrake/user_informer.rb:12:in `call'
railties (4.1.6) lib/rails/engine.rb:514:in `call'
railties (4.1.6) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
webrick (1.3.1) lib/webrick/httpserver.rb:138:in `service'
webrick (1.3.1) lib/webrick/httpserver.rb:94:in `run'
webrick (1.3.1) lib/webrick/server.rb:191:in `start_thread'
kernel/bootstrap/proc.rb:20:in `call'
kernel/bootstrap/thread.rb:391:in `__run__'
I'm blaming binding_of_caller
as better_errors will work without it. Please inform me if any additional information is needed.
When added to a rails app it fails with an
undefined method `[]' for nil:NilClass
when there is an error in a sass file (i.e. a missing variable).
Hey,
as @badosu fixed my problems with jruby (thanks for that!), I tried again starting new with a fresh rails app composer app (Gemfile here: https://gist.github.com/ni-ka/6811586)
Unfortunately I am getting the following error. Bettererrors works fine if I remove binding_of_caller. I started the app with JRUBY_OPTS=-X-C rails s
Started GET "/" for 127.0.0.1 at 2013-10-03 17:13:55 +0200
ArgumentError - index out of bounds for java array (-1 for length 160):
org/jruby/java/proxies/ArrayJavaProxy.java:79:in []' () Users/nils/.rvm/gems/jruby-1.7.4@bettertest/bundler/gems/binding_of_caller-132db08acaf0/lib/binding_of_caller/jruby_interpreted.rb:20:in
binding_of_caller'
() Users/nils/.rvm/gems/jruby-1.7.4@bettertest/bundler/gems/binding_of_caller-132db08acaf0/lib/binding_of_caller/jruby_interpreted.rb:33:in of_caller' () Users/nils/.rvm/gems/jruby-1.7.4@bettertest/bundler/gems/binding_of_caller-132db08acaf0/lib/binding_of_caller/jruby_interpreted.rb:37:in
callers'
org/jruby/RubyRange.java:459:in each' org/jruby/RubyEnumerable.java:713:in
map'
() Users/nils/.rvm/gems/jruby-1.7.4@bettertest/bundler/gems/binding_of_caller-132db08acaf0/lib/binding_of_caller/jruby_interpreted.rb:37:in callers' better_errors (1.0.1) lib/better_errors/core_ext/exception.rb:9:in
set_backtrace'
actionpack (4.0.0) lib/abstract_controller/helpers.rb:152:in initialize' actionpack (4.0.0) lib/abstract_controller/helpers.rb:137:in
modules_for_helpers'
org/jruby/RubyArray.java:2449:in map!' actionpack (4.0.0) lib/abstract_controller/helpers.rb:130:in
modules_for_helpers'
actionpack (4.0.0) lib/action_controller/metal/helpers.rb:89:in modules_for_helpers' actionpack (4.0.0) lib/abstract_controller/helpers.rb:94:in
helper'
actionpack (4.0.0) lib/abstract_controller/helpers.rb:171:in default_helper_module!' actionpack (4.0.0) lib/abstract_controller/helpers.rb:22:in
inherited'
org/jruby/RubyModule.java:2245:in module_eval' actionpack (4.0.0) lib/abstract_controller/helpers.rb:22:in
inherited'
actionpack (4.0.0) lib/action_controller/metal/params_wrapper.rb:226:in inherited' actionpack (4.0.0) lib/abstract_controller/railties/routes_helpers.rb:7:in
inherited'
actionpack (4.0.0) lib/action_controller/railties/helpers.rb:5:in inherited' app/controllers/visitors_controller.rb:1:in
(root)'
org/jruby/RubyKernel.java:1073:in load' activesupport (4.0.0) lib/active_support/dependencies.rb:1:in
(root)'
activesupport (4.0.0) lib/active_support/dependencies.rb:423:in load_file' activesupport (4.0.0) lib/active_support/dependencies.rb:615:in
new_constants_in'
activesupport (4.0.0) lib/active_support/dependencies.rb:422:in load_file' activesupport (4.0.0) lib/active_support/dependencies.rb:323:in
require_or_load'
activesupport (4.0.0) lib/active_support/dependencies.rb:462:in load_missing_constant' org/jruby/RubyModule.java:2546:in
const_get'
activesupport (4.0.0) lib/active_support/dependencies.rb:183:in const_missing' org/jruby/RubyArray.java:1617:in
each'
org/jruby/RubyEnumerable.java:815:in inject' activesupport (4.0.0) lib/active_support/inflector/methods.rb:226:in
constantize'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in constantize' activesupport (4.0.0) lib/active_support/dependencies.rb:534:in
get'
activesupport (4.0.0) lib/active_support/dependencies.rb:565:in constantize' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:76:in
controller_reference'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:66:in controller' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:44:in
call'
org/jruby/RubyArray.java:1617:in each' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in
call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in call' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in
call'
rack (1.5.2) lib/rack/etag.rb:23:in call' rack (1.5.2) lib/rack/conditionalget.rb:25:in
call'
rack (1.5.2) lib/rack/head.rb:11:in call' actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in
call'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:in
context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in
call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in call' org/jruby/RubyBasicObject.java:1703:in
send'
org/jruby/RubyKernel.java:2209:in send' activesupport (4.0.0) lib/active_support/callbacks.rb:376:in
_run__2080399955__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in run_callbacks' actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in
call'
actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in call' actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in
call'
better_errors (1.0.1) lib/better_errors/middleware.rb:84:in protected_app_call' better_errors (1.0.1) lib/better_errors/middleware.rb:79:in
better_errors_call'
better_errors (1.0.1) lib/better_errors/middleware.rb:56:in call' actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in
call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.0.0) lib/rails/rack/logger.rb:38:in
call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in call' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in
tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in tagged' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in
tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in call' quiet_assets (1.0.2) lib/quiet_assets.rb:18:in
call_with_quiet_assets'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in call' rack (1.5.2) lib/rack/methodoverride.rb:21:in
call'
rack (1.5.2) lib/rack/runtime.rb:17:in call' activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in
call'
rack (1.5.2) lib/rack/lock.rb:17:in call' actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in
call'
railties (4.0.0) lib/rails/engine.rb:511:in call' railties (4.0.0) lib/rails/application.rb:97:in
call'
rack (1.5.2) lib/rack/lock.rb:17:in call' rack (1.5.2) lib/rack/content_length.rb:14:in
call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in service' /Users/nils/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/webrick/httpserver.rb:138:in
service'
/Users/nils/.rvm/rubies/jruby-1.7.4/lib/ruby/1.9/webrick/httpserver.rb:94:in `run'
It's not clear for me how I can run the tests of this gem. Could you explain that in the README please?
rake test
fails for Ruby 2.2.2 on Mac OS X with the following message:
bacon -Itest -rubygems -a -q
rake aborted!
Command failed with status (127): [bacon -Itest -rubygems -a -q...]
/Users/josua/projects/binding_of_caller/Rakefile:54:in `block in <top (required)>'
Tasks: TOP => test
(See full trace by running task with --trace)
Here's the topic heartcombo/simple_form#1237
Please pay your attention.
to get the associated block for a stack frame
Here's a crash backtrace:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000003930
gc_mark [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/gc.c:1632
1632 if (obj->as.basic.flags == 0) return; /* free cell */
(gdb) bt
#0 gc_mark [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/gc.c:1632
#1 0x000000010005af9c in rb_gc_mark (ptr=14640) at gc.c:1655
#2 0x000000010016ae75 in env_mark (ptr=0x100663f00) at vm.c:251
#3 0x000000010005a204 in gc_mark_children (objspace=0x10081a800, ptr=4312121760, lev=1) at gc.c:1860
#4 0x000000010016aecc in rb_thread_mark (ptr=0x100401c20) at vm.c:1722
#5 0x000000010005a204 in gc_mark_children (objspace=0x10081a800, ptr=4303788480, lev=1) at gc.c:1860
#6 0x000000010016adb9 in vm_mark_each_thread_func (key=<value temporarily unavailable, due to optimizations>, value=<value temporarily unavailable, due to optimizations>, dummy=<value temporarily unavailable, due to optimizations>) at vm.c:1553
#7 0x00000001001100e0 in st_foreach (table=0x100413f30, func=0x10016adb0 <vm_mark_each_thread_func>, arg=0) at st.c:747
#8 0x000000010016c9ad in rb_vm_mark (ptr=0x100401840) at vm.c:1576
#9 0x000000010005a204 in gc_mark_children (objspace=0x10081a800, ptr=4303788520, lev=1) at gc.c:1860
#10 0x000000010005c6e3 in gc_marks (objspace=0x10081a800) at gc.c:1649
#11 0x000000010005d745 in before_gc_sweep [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/gc.c:2194
#12 0x000000010005d745 in rb_newobj () at gc.c:1655
#13 0x00000001001181bf in str_alloc [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/string.c:373
#14 0x00000001001181bf in str_new (klass=4303856400, ptr=0x101094883 " # @private\n def initialize(object, method_name, proxy)\n @method_name = method_name\n @object = object\n @proxy = proxy\n\n @method_stasher = InstanceMethodStasher.ne"..., len=17) at string.c:1655
#15 0x000000010007590a in rb_io_getline_1 (rs=4303815520, limit=-1, io=4303479800) at io.c:2653
#16 0x00000001000ad199 in lex_getline [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/parse.y:5280
#17 0x00000001000ad199 in parser_yylex (parser=0x100672de0) at parse.y:1655
#18 0x00000001000b5179 in ruby_yyparse (parser=<value temporarily unavailable, due to optimizations>) at parse.y:7938
#19 0x00000001000c2c9f in yycompile0 (arg=<value temporarily unavailable, due to optimizations>, tracing=<value temporarily unavailable, due to optimizations>) at parse.y:5217
#20 0x000000010018bfd3 in thread_suppress_tracing (th=0x100401c20, ev=<value temporarily unavailable, due to optimizations>, func=0x1000c2be0 <yycompile0>, arg=4301729248, always=<value temporarily unavailable, due to optimizations>) at thread.c:4578
#21 0x00000001000a0910 in rb_parser_compile_file (vparser=4303480000, f=0x100645220 "/Users/charlie/.rvm/gems/ruby-1.9.3-p327/gems/rspec-mocks-2.12.0/lib/rspec/mocks/method_double.rb", file=4303479800, start=1) at parse.y:5243
#22 0x00000001001067dc in load_file_internal (arg=<value temporarily unavailable, due to optimizations>) at ruby.c:1649
#23 0x0000000100042b4f in rb_ensure (b_proc=0x1001066f0 <load_file_internal>, data1=140734799790912, e_proc=0x100104310 <restore_lineno>, data2=1) at eval.c:744
#24 0x0000000100104abe in rb_load_file (fname=0x100645220 "/Users/charlie/.rvm/gems/ruby-1.9.3-p327/gems/rspec-mocks-2.12.0/lib/rspec/mocks/method_double.rb") at ruby.c:1686
#25 0x00000001000460aa in rb_load_internal (fname=4303481080, wrap=<value temporarily unavailable, due to optimizations>) at load.c:306
#26 0x00000001000474cc in rb_require_safe (fname=4303654600, safe=0) at load.c:620
#27 0x0000000100184627 in vm_call_cfunc [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/vm_insnhelper.c:404
#28 0x0000000100184627 in vm_call_method (th=0x100401c20, cfp=0x1005ff3f8, num=1, blockptr=0x1, flag=8, id=<value temporarily unavailable, due to optimizations>, me=0x10186d970, recv=4303859480) at vm_insnhelper.c:1655
#29 0x0000000100174522 in vm_exec_core (th=0x100401c20, initial=<value temporarily unavailable, due to optimizations>) at insns.def:1018
#30 0x0000000100178da3 in vm_exec (th=0x100401c20) at vm.c:1223
#31 0x0000000100179370 in rb_iseq_eval (iseqval=4303645760) at vm.c:1450
#32 0x000000010004610b in rb_load_internal (fname=4303657800, wrap=<value temporarily unavailable, due to optimizations>) at load.c:310
#33 0x00000001000474cc in rb_require_safe (fname=4303665920, safe=0) at load.c:620
#34 0x0000000100184627 in vm_call_cfunc [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/vm_insnhelper.c:404
#35 0x0000000100184627 in vm_call_method (th=0x100401c20, cfp=0x1005ff558, num=1, blockptr=0x1, flag=8, id=<value temporarily unavailable, due to optimizations>, me=0x10186d970, recv=4303859480) at vm_insnhelper.c:1655
#36 0x0000000100174522 in vm_exec_core (th=0x100401c20, initial=<value temporarily unavailable, due to optimizations>) at insns.def:1018
#37 0x0000000100178da3 in vm_exec (th=0x100401c20) at vm.c:1223
#38 0x0000000100179370 in rb_iseq_eval (iseqval=4303701760) at vm.c:1450
#39 0x000000010004610b in rb_load_internal (fname=4312197960, wrap=<value temporarily unavailable, due to optimizations>) at load.c:310
#40 0x00000001000474cc in rb_require_safe (fname=4312199320, safe=0) at load.c:620
#41 0x0000000100184627 in vm_call_cfunc [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/vm_insnhelper.c:404
#42 0x0000000100184627 in vm_call_method (th=0x100401c20, cfp=0x1005ff6b8, num=1, blockptr=0x1, flag=8, id=<value temporarily unavailable, due to optimizations>, me=0x10186d970, recv=4303859480) at vm_insnhelper.c:1655
#43 0x0000000100174522 in vm_exec_core (th=0x100401c20, initial=<value temporarily unavailable, due to optimizations>) at insns.def:1018
#44 0x0000000100178da3 in vm_exec (th=0x100401c20) at vm.c:1223
#45 0x0000000100179370 in rb_iseq_eval (iseqval=4312127600) at vm.c:1450
#46 0x000000010004610b in rb_load_internal (fname=4303767560, wrap=<value temporarily unavailable, due to optimizations>) at load.c:310
#47 0x00000001000474cc in rb_require_safe (fname=4328992600, safe=0) at load.c:620
#48 0x0000000100184627 in vm_call_cfunc [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/vm_insnhelper.c:404
#49 0x0000000100184627 in vm_call_method (th=0x100401c20, cfp=0x1005ff870, num=1, blockptr=0x1, flag=8, id=<value temporarily unavailable, due to optimizations>, me=0x10186d970, recv=4329380560) at vm_insnhelper.c:1655
#50 0x0000000100174522 in vm_exec_core (th=0x100401c20, initial=<value temporarily unavailable, due to optimizations>) at insns.def:1018
#51 0x0000000100178da3 in vm_exec (th=0x100401c20) at vm.c:1223
#52 0x0000000100179370 in rb_iseq_eval (iseqval=4328956120) at vm.c:1450
#53 0x000000010004610b in rb_load_internal (fname=4328973600, wrap=<value temporarily unavailable, due to optimizations>) at load.c:310
#54 0x000000010004792d in rb_f_load (argc=<value temporarily unavailable, due to optimizations>, argv=<value temporarily unavailable, due to optimizations>) at load.c:384
#55 0x0000000100184627 in vm_call_cfunc [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/vm_insnhelper.c:404
#56 0x0000000100184627 in vm_call_method (th=0x100401c20, cfp=0x1005ffce8, num=1, blockptr=0x1, flag=8, id=<value temporarily unavailable, due to optimizations>, me=0x100477100, recv=4329380560) at vm_insnhelper.c:1655
#57 0x0000000100174522 in vm_exec_core (th=0x100401c20, initial=<value temporarily unavailable, due to optimizations>) at insns.def:1018
#58 0x0000000100178da3 in vm_exec (th=0x100401c20) at vm.c:1223
#59 0x000000010018959e in rb_yield (val=4328974760) at vm.c:657
#60 0x00000001000093ae in rb_ary_each (array=<value temporarily unavailable, due to optimizations>) at array.c:1495
#61 0x0000000100184627 in vm_call_cfunc [inlined] () at /Users/charlie/.rvm/src/ruby-1.9.3-p327/vm_insnhelper.c:404
#62 0x0000000100184627 in vm_call_method (th=0x100401c20, cfp=0x1005ffdf0, num=0, blockptr=0x1005ffe19, flag=0, id=<value temporarily unavailable, due to optimizations>, me=0x100444a10, recv=4328973760) at vm_insnhelper.c:1655
#63 0x0000000100174522 in vm_exec_core (th=0x100401c20, initial=<value temporarily unavailable, due to optimizations>) at insns.def:1018
#64 0x0000000100178da3 in vm_exec (th=0x100401c20) at vm.c:1223
#65 0x000000010017a3ad in rb_vm_invoke_proc (th=<value temporarily unavailable, due to optimizations>, proc=0x101809fb0, self=4329998640, argc=0, argv=0x1020d2bc0, blockptr=0x0) at vm.c:627
#66 0x000000010004572c in rb_exec_end_proc () at eval_jump.c:126
#67 0x0000000100045845 in ruby_finalize_0 () at eval.c:92
#68 0x0000000100045980 in ruby_cleanup (ex=0) at eval.c:133
#69 0x0000000100045cd3 in ruby_run_node (n=<value temporarily unavailable, due to optimizations>) at eval.c:244
#70 0x0000000100000edf in main (argc=2, argv=0x7fff5fbff368) at main.c:38
Valgrind complains a little bit too, so I'll attach that:
==25157== Invalid read of size 8
==25157== at 0x1748E0: vm_make_env_each (vm.c:364)
==25157== by 0x174C44: rb_vm_make_env_object (vm.c:480)
==25157== by 0xC108CA: binding_of_caller (binding_of_caller.c:151)
==25157== by 0xC10B1F: callers (binding_of_caller.c:207)
==25157== by 0x18B626: vm_call_method (vm_insnhelper.c:404)
==25157== by 0x17B521: vm_exec_core (insns.def:1018)
==25157== by 0x17FDA2: vm_exec (vm.c:1223)
==25157== by 0x1813AC: rb_vm_invoke_proc (vm.c:627)
==25157== by 0x181885: vm_call0 (vm_insnhelper.c:433)
==25157== by 0x184ABD: rb_funcall2 (vm_eval.c:236)
==25157== by 0x9D632: rb_class_new_instance (object.c:1636)
==25157== by 0x1817F1: vm_call0 (vm_eval.c:79)
==25157== Address 0x101ad1370 is 16 bytes inside a block of size 32 free'd
==25157== at 0x506E: free (vg_replace_malloc.c:430)
==25157== by 0x171ACD: env_free (vm.c:273)
==25157== by 0x5EAB3: finalize_list (gc.c:2932)
==25157== by 0x1970A4: rb_threadptr_execute_interrupts_common (thread.c:1311)
==25157== by 0x1820F2: vm_call0 (vm_eval.c:147)
==25157== by 0x185C4D: rb_funcall (vm_eval.c:236)
==25157== by 0x10D7C8: load_file_internal (ruby.c:1648)
==25157== by 0x49B4E: rb_ensure (eval.c:744)
==25157== by 0x10BABD: rb_load_file (ruby.c:1686)
==25157== by 0x4D0A9: rb_load_internal (load.c:306)
==25157== by 0x4E4CB: rb_require_safe (load.c:620)
==25157== by 0x18B626: vm_call_method (vm_insnhelper.c:404)
==25157==
......................................
Finished in 5.64 seconds
38 examples, 0 failures
==25157== Invalid read of size 4
==25157== at 0x181110: rb_vm_invoke_proc (vm.c:677)
==25157== by 0x4C72B: rb_exec_end_proc (eval_jump.c:126)
==25157== by 0x4C844: ruby_finalize_0 (eval.c:92)
==25157== by 0x4C97F: ruby_cleanup (eval.c:133)
==25157== by 0x4CCD2: ruby_run_node (eval.c:244)
==25157== by 0x100000EDE: main (main.c:38)
==25157== Address 0x101ad13fc is not stack'd, malloc'd or (recently) free'd
==25157==
Hope this helps.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/ruby/ruby-2.0.0-0/bin/ruby extconf.rb
creating Makefile
make
compiling binding_of_caller.c
binding_of_caller.c:4:21: error: vm_core.h: No such file or directory
binding_of_caller.c:5:16: error: gc.h: No such file or directory
binding_of_caller.c: In function ‘binding_memsize’:
binding_of_caller.c:33: error: ‘rb_binding_t’ undeclared (first use in this function)
binding_of_caller.c:33: error: (Each undeclared identifier is reported only once
binding_of_caller.c:33: error: for each function it appears in.)
binding_of_caller.c: In function ‘binding_free’:
binding_of_caller.c:39: error: ‘rb_binding_t’ undeclared (first use in this function)
binding_of_caller.c:39: error: ‘bind’ undeclared (first use in this function)
binding_of_caller.c:40: warning: implicit declaration of function ‘RUBY_FREE_ENTER’
binding_of_caller.c:45: warning: implicit declaration of function ‘RUBY_FREE_LEAVE’
binding_of_caller.c: In function ‘binding_mark’:
binding_of_caller.c:51: error: ‘rb_binding_t’ undeclared (first use in this function)
binding_of_caller.c:51: error: ‘bind’ undeclared (first use in this function)
binding_of_caller.c:52: warning: implicit declaration of function ‘RUBY_MARK_ENTER’
binding_of_caller.c:55: warning: implicit declaration of function ‘RUBY_MARK_UNLESS_NULL’
binding_of_caller.c:62: warning: implicit declaration of function ‘RUBY_MARK_LEAVE’
binding_of_caller.c: At top level:
binding_of_caller.c:67: warning: missing braces around initializer
binding_of_caller.c:67: warning: (near initialization for ‘binding_data_type.function’)
binding_of_caller.c: In function ‘binding_alloc’:
binding_of_caller.c:76: error: ‘rb_binding_t’ undeclared (first use in this function)
binding_of_caller.c:76: error: ‘bind’ undeclared (first use in this function)
binding_of_caller.c:77: error: expected expression before ‘)’ token
binding_of_caller.c:77: warning: left-hand operand of comma expression has no effect
binding_of_caller.c:77: warning: left-hand operand of comma expression has no effect
binding_of_caller.c: At top level:
binding_of_caller.c:81: error: expected ‘)’ before ‘’ token
binding_of_caller.c:85: error: expected ‘)’ before ‘’ token
binding_of_caller.c:89: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘’ token
binding_of_caller.c: In function ‘frametype_name’:
binding_of_caller.c:107: error: ‘VM_FRAME_MAGIC_MASK’ undeclared (first use in this function)
binding_of_caller.c:108: error: ‘VM_FRAME_MAGIC_METHOD’ undeclared (first use in this function)
binding_of_caller.c:109: error: ‘VM_FRAME_MAGIC_BLOCK’ undeclared (first use in this function)
binding_of_caller.c:110: error: ‘VM_FRAME_MAGIC_CLASS’ undeclared (first use in this function)
binding_of_caller.c:111: error: ‘VM_FRAME_MAGIC_TOP’ undeclared (first use in this function)
binding_of_caller.c:112: error: ‘VM_FRAME_MAGIC_FINISH’ undeclared (first use in this function)
binding_of_caller.c:113: error: ‘VM_FRAME_MAGIC_CFUNC’ undeclared (first use in this function)
binding_of_caller.c:114: error: ‘VM_FRAME_MAGIC_PROC’ undeclared (first use in this function)
binding_of_caller.c:115: error: ‘VM_FRAME_MAGIC_IFUNC’ undeclared (first use in this function)
binding_of_caller.c:116: error: ‘VM_FRAME_MAGIC_EVAL’ undeclared (first use in this function)
binding_of_caller.c:117: error: ‘VM_FRAME_MAGIC_LAMBDA’ undeclared (first use in this function)
binding_of_caller.c: In function ‘binding_of_caller’:
binding_of_caller.c:125: error: ‘rb_thread_t’ undeclared (first use in this function)
binding_of_caller.c:125: error: ‘th’ undeclared (first use in this function)
binding_of_caller.c:126: warning: implicit declaration of function ‘GetThreadPtr’
binding_of_caller.c:128: error: ‘rb_control_frame_t’ undeclared (first use in this function)
binding_of_caller.c:128: error: ‘cfp’ undeclared (first use in this function)
binding_of_caller.c:128: warning: implicit declaration of function ‘RUBY_VM_PREVIOUS_CONTROL_FRAME’
binding_of_caller.c:129: error: ‘limit_cfp’ undeclared (first use in this function)
binding_of_caller.c:130: warning: ISO C90 forbids mixed declarations and code
binding_of_caller.c:140: warning: implicit declaration of function ‘valid_frame_p’
binding_of_caller.c:141: warning: implicit declaration of function ‘find_valid_frame’
binding_of_caller.c:144: warning: ISO C90 forbids mixed declarations and code
binding_of_caller.c:145: error: ‘rb_binding_t’ undeclared (first use in this function)
binding_of_caller.c:145: error: ‘bind’ undeclared (first use in this function)
binding_of_caller.c:150: warning: implicit declaration of function ‘GetBindingPtr’
binding_of_caller.c:151: warning: implicit declaration of function ‘rb_vm_make_env_object’
binding_of_caller.c:153: warning: implicit declaration of function ‘rb_vm_get_sourceline’
binding_of_caller.c: In function ‘frame_count’:
binding_of_caller.c:175: error: ‘rb_thread_t’ undeclared (first use in this function)
binding_of_caller.c:175: error: ‘th’ undeclared (first use in this function)
binding_of_caller.c:178: error: ‘rb_control_frame_t’ undeclared (first use in this function)
binding_of_caller.c:178: error: ‘cfp’ undeclared (first use in this function)
binding_of_caller.c:179: error: ‘limit_cfp’ undeclared (first use in this function)
binding_of_caller.c:181: warning: ISO C90 forbids mixed declarations and code
make: ** [binding_of_caller.o] Error 1
Gem files will remain installed in /usr/local/ruby/ruby-2.0.0-0/lib/ruby/gems/2.0.0/gems/binding_of_caller-0.6.8 for inspection.
Results logged to /usr/local/ruby/ruby-2.0.0-0/lib/ruby/gems/2.0.0/gems/binding_of_caller-0.6.8/ext/binding_of_caller/gem_make.out
An error occurred while installing binding_of_caller (0.6.8), and Bundler cannot continue.
Make sure that gem install binding_of_caller -v '0.6.8'
succeeds before bundling.
I honestly have lost track of why this gem was in use in some of my projects, but I noticed after upgrading to Ruby 2.5, rspec had no stack trace to report, Rails console would shut down if an exception was raised, better_errors had no stack trace to show, etc. Removing the gem fixed the problem.
It is unclear what changed from 0.7.3pre to 0.7.3 and from 0.7.3 to 0.8
Rails 5.1.4
Ruby 2.3.5
While the server is running and I will attempt to edit a custom Helper (which builds a layout). After sending a GET request to refresh the page and see the layout changes, the application seizes up and stops responding. After removing 'binding of caller' from my Gemfile, it no longer has any issues showing my changes to the file. Despite trying to figure out a workaround, I have been unable to continue using Binding of Caller in my application.
For reference, this is my console output:
# better errors trying to resolve the broken helper method
Started POST "/__better_errors/346947eb36a45685/variables" for ::1 at 2017-10-18 16:05:15 -0500
# GET request after I fix the helper method
Started GET "/admin/shoots?show=past" for ::1 at 2017-10-18 16:05:20 -0500
The log doesn't output anything else. The GET request is my attempt at reloading the page after making changes to the Helper file. But it just sits there indefinitely while the browser indefinitely waits for a response.
After performing a kill -9 ${PID}
to the PID, I am able to restart the server and my helper method compiles the HTML and my server responds. But until then, there is nothing I'm able to do on the application.
Rails 6.0.3
Ruby 2.6.6
While this gem is included in project, I can't see rails view error in Rails Error page. Following image is shown when gem is included in project
# Gemfile
group :development do
gem 'binding_of_caller'
end
and this image is when I remove 'binding_of_caller' gem in project
# Gemfile
group :development do
# gem 'binding_of_caller'
end
It seems like there is some issue with code change in rails 6.
I use better_errors with boc. Here are my finding running my app unchanged on ruby 2p247:
Ruby | Without boc | With boc (0.7.2) | Diff |
---|---|---|---|
1.9.3p429 | 3s | 5s | +60% |
2p247 | 3s | 11s | +260% |
Any reason for this? I thought going to Ruby 2 would speed up things, not slowing things down :o$
It might be too coupled to Rails but lazy-loading ActiveRecord objects (if possible) would be great.
I want warp offical binding.break
into a method, assume, named: brk!
.
following is attempt: (compare to pry)
require 'binding_of_caller'
class Binding
def _break
require 'debug'
warn 'laoding break'
self.break
end
def _pry
require 'pry'
warn 'loading pry'
self.pry
end
end
class Object
def brk!
binding.of_caller(1)._break
end
def pry!
binding.of_caller(1)._pry
end
end
What i expected is, wrappered brk! behavior like wrapped pry!.
e.g. asssume, we have 1.rb code like this:
puts 100
pry!
puts 200
when run with ruby 1.rb
, get this: (it was expected)
But, when if change code to this:
puts 100
brk!
puts 200
when run ruby 1.rb
, get this. (it was unexpected)
as you can see, the =>
not stop on correct position. (which we expected to on same line as brk! as pry! does)
Thank you.
/Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/binding_of_caller-0.7.2/lib/binding_of_caller/mri2.rb:21:in `callers': uninitialized constant RubyVM::DebugInspector (NameError)
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/better_errors-0.3.2/lib/better_errors/core_ext/exception.rb:9:in `block in <class:Exception>'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.16/lib/active_support/testing/deprecation.rb:39:in `new'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.16/lib/active_support/testing/deprecation.rb:39:in `require'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.16/lib/active_support/testing/deprecation.rb:39:in `<top (required)>'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.16/lib/active_support/test_case.rb:4:in `require'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.16/lib/active_support/test_case.rb:4:in `<top (required)>'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-3.2.16/lib/action_controller/test_case.rb:355:in `<module:ActionController>'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-3.2.16/lib/action_controller/test_case.rb:7:in `<top (required)>'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/shoulda-matchers-1.4.1/lib/shoulda/matchers/integrations/test_unit.rb:6:in `<top (required)>'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/shoulda-matchers-1.4.1/lib/shoulda/matchers.rb:8:in `require'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/shoulda-matchers-1.4.1/lib/shoulda/matchers.rb:8:in `<top (required)>'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/shoulda-matchers-1.4.1/lib/shoulda-matchers.rb:1:in `require'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/shoulda-matchers-1.4.1/lib/shoulda-matchers.rb:1:in `<top (required)>'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /Users/hippo/Development/responsive/config/application.rb:13:in `<top (required)>'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.16/lib/rails/commands.rb:53:in `require'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.16/lib/rails/commands.rb:53:in `block in <top (required)>'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.16/lib/rails/commands.rb:50:in `tap'
from /Users/hippo/.rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.16/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Any idea what is going on here?
when i run bundle install
, it failed
here is the error message
Installing binding_of_caller (0.6.8)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/lazywei/.rbenv/versions/2.0.0-p0/bin/ruby extconf.rb
creating Makefile
make
compiling binding_of_caller.c
binding_of_caller.c:4:10: fatal error: 'vm_core.h' file not found
#include "vm_core.h"
^
1 error generated.
make: *** [binding_of_caller.o] Error 1
When trying to start the rails server with ruby 3.0.0-preview1, it won't start unless binding_of_caller is removed from the gemset. Here are the logs:
/me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in require': cannot load such file -- binding_of_caller.bundle (LoadError) from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in
block in require'
from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in load_dependency' from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in
require'
from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/binding_of_caller-0.8.0/lib/binding_of_caller.rb:9:in <top (required)>' from /me/.rvm/rubies/ruby-3.0.0-preview1/lib/ruby/3.0.0/bundler/runtime.rb:66:in
require'
from /me/.rvm/rubies/ruby-3.0.0-preview1/lib/ruby/3.0.0/bundler/runtime.rb:66:in block (2 levels) in require' from /me/.rvm/rubies/ruby-3.0.0-preview1/lib/ruby/3.0.0/bundler/runtime.rb:61:in
each'
from /me/.rvm/rubies/ruby-3.0.0-preview1/lib/ruby/3.0.0/bundler/runtime.rb:61:in block in require' from /me/.rvm/rubies/ruby-3.0.0-preview1/lib/ruby/3.0.0/bundler/runtime.rb:50:in
each'
from /me/.rvm/rubies/ruby-3.0.0-preview1/lib/ruby/3.0.0/bundler/runtime.rb:50:in require' from /me/.rvm/rubies/ruby-3.0.0-preview1/lib/ruby/3.0.0/bundler.rb:174:in
require'
from /me/Apps/reactisviewcancer/config/application.rb:21:in <top (required)>' from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in
require'
from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in block in require' from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in
load_dependency'
from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in require' from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/railties-6.0.3.4/lib/rails/commands/server/server_command.rb:141:in
block in perform'
from internal:kernel:90:in tap' from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/railties-6.0.3.4/lib/rails/commands/server/server_command.rb:138:in
perform'
from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/thor-1.0.1/lib/thor/command.rb:27:in run' from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in
invoke_command'
from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/thor-1.0.1/lib/thor.rb:392:in dispatch' from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/railties-6.0.3.4/lib/rails/command/base.rb:69:in
perform'
from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/railties-6.0.3.4/lib/rails/command.rb:46:in invoke' from /me/Apps/reactisviewcancer/vendor/bundle/ruby/3.0.0/gems/railties-6.0.3.4/lib/rails/commands.rb:18:in
<top (required)>'
from bin/rails:9:in require' from bin/rails:9:in
Just came across this project from better_errors
. I would love to be able to use it, however we're stuck on JRuby and cannot use it since it has C extensions.
I don't even know how to write a jruby compatible version or whatever, but is there any movement to support JRuby?
To reproduce:
git clone http://github.com/ConradIrwin/lspace
bundle
rspec
Will segfault reliably.
I got this error after adding the gem, the browser keep loading then WEBrick throw this error.
I'm using rails 4.1.5
Attempting to run the test suite fails with:
NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed on or after 2018-12-01.
Gem::Specification#has_rdoc= called from /tmp/guix-build-ruby-binding-of-caller-0.8.0.drv-0/gem/Rakefile:34.
rake aborted!
Using Ruby 2.6.5.
On a system, where a gc.h file is available, the gem is compiled properly.
Symptom:
dyld: lazy symbol binding failed: Symbol not found: _RUBY_FREE_ENTER
This is caused by finding a copy of boehm's gc.h before finding ruby's gc.h.
I'll submit a patch.
I'm using better_errors
and binding_of_caller
in a Rails app with activeadmin
.
It works fine when there is any error in Rails controller. But if the controller belongs to activeadmin
part of the code, I can see the memory keeps going up and the page hangs. Memory always seems to go up to 1.5gb and above.
I'm using Rails 4.0.
On FreeBSD you get the following error:
/libexec/ld-elf.so.1: /usr/local/lib/ruby/gems/1.9/gems/binding_of_caller-0.6.8/lib/binding_of_caller.so: Undefined symbol "RUBY_FREE_ENTER"
I totally do not have a clue thats wrong, please help me out :=)
$ uname -r 2.6.32-431.11.2.el6.x86_64
$ gem --version 1.3.7
$ ruby --version ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
$ gem install binding_of_caller
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
creating Makefile
make
gcc -I. -I/usr/lib64/ruby/1.8/x86_64-linux -I/usr/lib64/ruby/1.8/x86_64-linux -I. -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fno-strict-aliasing -fPIC -O0 -std=c99 -c binding_of_caller.c
binding_of_caller.c:4:21: error: vm_core.h: No such file or directory
binding_of_caller.c:5:22: error: rubys_gc.h: No such file or directory
binding_of_caller.c:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
binding_of_caller.c: In function ‘binding_memsize’:
binding_of_caller.c:34: error: ‘rb_binding_t’ undeclared (first use in this function)
binding_of_caller.c:34: error: (Each undeclared identifier is reported only once
binding_of_caller.c:34: error: for each function it appears in.)
binding_of_caller.c: In function ‘binding_free’:
binding_of_caller.c:40: error: ‘rb_binding_t’ undeclared (first use in this function)
binding_of_caller.c:40: error: ‘bind’ undeclared (first use in this function)
binding_of_caller.c:41: warning: implicit declaration of function ‘RUBY_FREE_ENTER’
binding_of_caller.c:46: warning: implicit declaration of function ‘RUBY_FREE_LEAVE’
binding_of_caller.c: In function ‘binding_mark’:
binding_of_caller.c:52: error: ‘rb_binding_t’ undeclared (first use in this function)
binding_of_caller.c:52: error: ‘bind’ undeclared (first use in this function)
binding_of_caller.c:53: warning: implicit declaration of function ‘RUBY_MARK_ENTER’
binding_of_caller.c:56: warning: implicit declaration of function ‘RUBY_MARK_UNLESS_NULL’
binding_of_caller.c:63: warning: implicit declaration of function ‘RUBY_MARK_LEAVE’
binding_of_caller.c: At top level:
binding_of_caller.c:66: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘binding_data_type’
binding_of_caller.c: In function ‘binding_alloc’:
binding_of_caller.c:77: error: ‘rb_binding_t’ undeclared (first use in this function)
binding_of_caller.c:77: error: ‘bind’ undeclared (first use in this function)
binding_of_caller.c:78: warning: implicit declaration of function ‘TypedData_Make_Struct’
binding_of_caller.c:78: error: ‘binding_data_type’ undeclared (first use in this function)
binding_of_caller.c: At top level:
binding_of_caller.c:82: error: expected ‘)’ before ‘*’ token
binding_of_caller.c:86: error: expected ‘)’ before ‘*’ token
binding_of_caller.c:90: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
binding_of_caller.c: In function ‘frametype_name’:
binding_of_caller.c:108: error: ‘VM_FRAME_MAGIC_MASK’ undeclared (first use in this function)
binding_of_caller.c:109: error: ‘VM_FRAME_MAGIC_METHOD’ undeclared (first use in this function)
binding_of_caller.c:110: error: ‘VM_FRAME_MAGIC_BLOCK’ undeclared (first use in this function)
binding_of_caller.c:111: error: ‘VM_FRAME_MAGIC_CLASS’ undeclared (first use in this function)
binding_of_caller.c:112: error: ‘VM_FRAME_MAGIC_TOP’ undeclared (first use in this function)
binding_of_caller.c:113: error: ‘VM_FRAME_MAGIC_CFUNC’ undeclared (first use in this function)
binding_of_caller.c:114: error: ‘VM_FRAME_MAGIC_PROC’ undeclared (first use in this function)
binding_of_caller.c:115: error: ‘VM_FRAME_MAGIC_IFUNC’ undeclared (first use in this function)
binding_of_caller.c:116: error: ‘VM_FRAME_MAGIC_EVAL’ undeclared (first use in this function)
binding_of_caller.c:117: error: ‘VM_FRAME_MAGIC_LAMBDA’ undeclared (first use in this function)
binding_of_caller.c: In function ‘binding_of_caller’:
binding_of_caller.c:125: error: ‘rb_thread_t’ undeclared (first use in this function)
binding_of_caller.c:125: error: ‘th’ undeclared (first use in this function)
binding_of_caller.c:126: warning: implicit declaration of function ‘GetThreadPtr’
binding_of_caller.c:128: error: ‘rb_control_frame_t’ undeclared (first use in this function)
binding_of_caller.c:128: error: ‘cfp’ undeclared (first use in this function)
binding_of_caller.c:128: warning: implicit declaration of function ‘RUBY_VM_PREVIOUS_CONTROL_FRAME’
binding_of_caller.c:129: error: ‘limit_cfp’ undeclared (first use in this function)
binding_of_caller.c:140: warning: implicit declaration of function ‘valid_frame_p’
binding_of_caller.c:141: warning: implicit declaration of function ‘find_valid_frame’
binding_of_caller.c:145: error: ‘rb_binding_t’ undeclared (first use in this function)
binding_of_caller.c:145: error: ‘bind’ undeclared (first use in this function)
binding_of_caller.c:150: warning: implicit declaration of function ‘GetBindingPtr’
binding_of_caller.c:152: warning: implicit declaration of function ‘rb_vm_make_env_object’
binding_of_caller.c:154: warning: implicit declaration of function ‘rb_vm_get_sourceline’
binding_of_caller.c: In function ‘frame_count’:
binding_of_caller.c:176: error: ‘rb_thread_t’ undeclared (first use in this function)
binding_of_caller.c:176: error: ‘th’ undeclared (first use in this function)
binding_of_caller.c:179: error: ‘rb_control_frame_t’ undeclared (first use in this function)
binding_of_caller.c:179: error: ‘cfp’ undeclared (first use in this function)
binding_of_caller.c:180: error: ‘limit_cfp’ undeclared (first use in this function)
make: *** [binding_of_caller.o] Error 1
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/binding_of_caller-0.7.2 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/binding_of_caller-0.7.2/ext/binding_of_caller/gem_make.out
An error occurred while installing binding_of_caller (0.7.2), and Bundler cannot continue.
Make sure that `gem install binding_of_caller -v '0.7.2'` succeeds before bundling.
I noticed this merge conflict: https://github.com/banister/binding_of_caller/blob/master/ext/binding_of_caller/ruby_headers/192/version.h#L2-10
Hasnt actually caused me an issue, but it looks a bit sloppy
It seems like ffi
should be possible to wrap the debugging API, without the need for native code compilation.
Is something along these lines possible?
#!/usr/bin/env ruby
require 'ffi'
module Peek
extend FFI::Library
ffi_lib "ruby"
# ./include/ruby/debug.h:43:typedef VALUE (*rb_debug_inspector_func_t)(const rb_debug_inspector_t *, void *);
# ./include/ruby/debug.h:45:VALUE rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data);
attach_function :rb_debug_inspector_open, [
callback([ :pointer, :pointer ], :pointer), :pointer
], :pointer
Callback = FFI::Function.new(:pointer, [:pointer, :pointer]) do |a, b|
'???'
end
end
p Peek.rb_debug_inspector_open(Peek::Callback, nil)
Installing binding_of_caller (0.7.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/Cellar/rbenv/0.4.0/versions/jruby-1.7.4/bin/jruby extconf.rb
NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=true to JRuby or set JRUBY_OPTS or modify .jrubyrc to enable.
(root) at /usr/local/Cellar/rbenv/0.4.0/versions/jruby-1.7.4/lib/ruby/shared/mkmf.rb:8
require at org/jruby/RubyKernel.java:1054
(root) at /usr/local/Cellar/rbenv/0.4.0/versions/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:1
(root) at extconf.rb:19
Gem files will remain installed in /usr/local/Cellar/rbenv/0.4.0/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/binding_of_caller-0.7.2 for inspection.
Results logged to /usr/local/Cellar/rbenv/0.4.0/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/binding_of_caller-0.7.2/ext/binding_of_caller/gem_make.out
An error occurred while installing binding_of_caller (0.7.2), and Bundler cannot
continue.
Make sure that `gem install binding_of_caller -v '0.7.2'` succeeds before
bundling.
Hi there,
Is there a chance to release a new version with the JRuby interpreted mode support baked in? Its been sitting in master for a while now.
As part of Rais 2014 GSoC, we're doing a debug console and we really wanna support JRuby as a lot of people are running it in production, hence in development too. Even with preconditions (interpreter mode being opt-in), we think the JRuby world will benefit of that.
I took a whack at it today, but hit a wall (vm_core.h
has been refactored significantly), and I was unable to get it to build.
Does anyone else have enough knowledge of Ruby's internals to get it building on 2.0?
I just pushed a simpler version of this gem called bindings
, which is available on rubygems. Just wanted to let others know, who might be looking for a simpler approach.
not working with ruby 2
bundle exec rake db:create
/home/manoj/.rvm/gems/[email protected]/gems/binding_of_caller-0.7.1/lib/binding_of_caller/mri2.rb:21: [BUG] Segmentation fault
ruby 2.0.0dev (2013-01-07 trunk 38733) [i686-linux]
-- Control frame information -----------------------------------------------
c:0036 p:---- s:0122 e:000121 CFUNC :open
c:0035 p:0021 s:0119 e:000118 METHOD /home/manoj/.rvm/gems/[email protected]/gems/binding_of_caller-0.7.1/lib/binding_of_caller/mri2.rb:21
c:0034 p:0046 s:0115 e:000ef8 LAMBDA /home/manoj/.rvm/gems/[email protected]/gems/better_errors-0.8.0/lib/better_errors/core_ext/exception.rb:9 [FINISH]
c:0033 p:---- s:0112 e:000111 CFUNC :new
c:0032 p:---- s:0110 e:000109 CFUNC :require
c:0031 p:0010 s:0106 e:000105 BLOCK /home/manoj/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251
c:0030 p:0054 s:0104 e:000103 METHOD /home/manoj/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236
c:0029 p:0015 s:0099 e:000098 METHOD /home/manoj/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251
c:0028 p:0025 s:0094 e:000093 METHOD /home/manoj/.rvm/gems/[email protected]/gems/bullet-4.5.0/lib/bullet/dependency.rb:5
c:0027 p:0058 s:0091 e:000090 CLASS /home/manoj/.rvm/gems/[email protected]/gems/bullet-4.5.0/lib/bullet.rb:14
c:0026 p:0049 s:0089 e:000088 TOP /home/manoj/.rvm/gems/[email protected]/gems/bullet-4.5.0/lib/bullet.rb:7 [FINISH]
c:0025 p:---- s:0087 e:000086 CFUNC :require
c:0024 p:0021 s:0083 e:000082 BLOCK /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72 [FINISH]
c:0023 p:---- s:0080 e:000079 CFUNC :�
c:0022 p:0055 s:0077 e:000076 BLOCK /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70 [FINISH]
c:0021 p:---- s:0070 e:000069 CFUNC :�
c:0020 p:0030 s:0067 e:000066 METHOD /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59
c:0019 p:0013 s:0063 e:000062 METHOD /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/bundler-1.3.5/lib/bundler.rb:132
c:0018 p:0069 s:0059 e:000058 TOP /home/manoj/projects/ninjaats/config/application.rb:7 [FINISH]
c:0017 p:---- s:0057 e:000056 CFUNC :require
c:0016 p:0018 s:0053 e:000052 TOP /home/manoj/projects/ninjaats/Rakefile:5 [FINISH]
c:0015 p:---- s:0051 e:000050 CFUNC :load
c:0014 p:0009 s:0047 e:000046 METHOD /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/rake-10.0.4/lib/rake/rake_module.rb:25
c:0013 p:0176 s:0043 e:000042 METHOD /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/rake-10.0.4/lib/rake/application.rb:589
c:0012 p:0007 s:0038 e:000037 BLOCK /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/rake-10.0.4/lib/rake/application.rb:89
c:0011 p:0008 s:0036 e:000035 METHOD /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/rake-10.0.4/lib/rake/application.rb:160
c:0010 p:0007 s:0032 e:000031 METHOD /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/rake-10.0.4/lib/rake/application.rb:88
c:0009 p:0013 s:0029 e:000028 BLOCK /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/rake-10.0.4/lib/rake/application.rb:72
c:0008 p:0008 s:0027 e:001d30 METHOD /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/rake-10.0.4/lib/rake/application.rb:160
c:0007 p:0007 s:0023 e:0023cc METHOD /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/rake-10.0.4/lib/rake/application.rb:70
c:0006 p:0040 s:0020 e:000cb4 TOP /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/gems/rake-10.0.4/bin/rake:33 [FINISH]
c:0005 p:---- s:0018 e:000017 CFUNC :load
c:0004 p:0095 s:0014 e:001850 EVAL /home/manoj/.rvm/gems/ruby-2.0.0-rc1@global/bin/rake:19 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC :eval
c:0002 p:0072 s:0005 e:0008c8 EVAL /home/manoj/.rvm/gems/[email protected]/bin/ruby_noexec_wrapper:14 [FINISH]
c:0001 p:0000 s:0002 e:000734 TOP [FINISH]
Hello,
We are experiencing significant slowness that seems to be caused by binding_of_caller
when it is used in conjunction with Puma 3.x and the better_errors
gem.
Puma 2.16.0 - no issues
Puma 3.0.0 and the latest 3.1.1 - slow to load.
The issue was originally opened as a better_errors issue, but it seems to be related to binding_of_caller
.
Any additional details we can provide to assist in the debugging?
Our project uses Honeybadger to capture information around unrescued exceptions. It has a feature that can capture all the local variables around an exception. (Exceptions: local_variables: true
) That feature uses your gem, binding_of_caller
We were super-excited to find that, but stopped short when we found your advice:
Recommended for use only in debugging situations. Do not use this in production apps.
Can you offer some more insight as to what some of the concerns are there?
Are there performance hits just for having the gem bundled? In our case, this would only come into play after an exception is raised, and we'd happily take that hit to get the insight. If it meant the entire app was slowed even if binding.of_caller
was never invoked, that would be a deal-killer for us in production.
Are there other known reasons why using this in prod is a bad idea?
I read https://www.reddit.com/r/ruby/comments/5rw9po/why_is_binding_of_caller_dirty/ We're running Ruby 3.1.2 (specifically, docker/library/ruby:3.1.2 ), so I'm not sure how that commentary from 2015 around Ruby 1.9 -> 2.x applies today.
I'm not looking for any guarantee or specific advice...just seeking more insight to help us make an informed decision on how we might use the gem.
Thanks so much for creating and maintaining this gem of a gem!
Using Ruby 2.0.0 and Rails version 3.2.12, my Rails app response times are at least tripled. Removing binding_of_caller
resolves this and the application behaves well.
I haven't looked into this any closer but wanted to note it down here.
Just started getting this deprecation warning.
.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/binding_of_caller-1.0.0/lib/binding_of_caller/mri.rb:21: warning: constant RubyVM::DebugInspector is deprecated
Looking into it a bit, it looks like debug_inspector
updated its name and usage in a recent release.
Does someone know of any doc regarding the development of jruby support on binding_of_caller
?
Hey,
I was curious about the Jruby support so tried to install it. However, it gives me the following errors (I ran "JRUBY_OPTS=-Xcext.enabled=true bundle install")
Using binding_of_caller (0.7.2) from https://github.com/banister/binding_of_caller.git (at master)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/nils/.rvm/rubies/jruby-1.7.4/bin/jruby extconf.rb
/Users/nils/.rvm/rubies/jruby-1.7.4/lib/ruby/shared/mkmf.rb:14: Use RbConfig instead of obsolete and deprecated Config.
creating Makefile
make
cc -I. -I/Users/nils/.rvm/rubies/jruby-1.7.4/lib/native/include -I/Users/nils/.rvm/rubies/jruby-1.7.4/lib/native/include/ruby -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fPIC -DTARGET_RT_MAC_CFM=0 -fno-omit-frame-pointer -fno-strict-aliasing -fexceptions -O0 -std=c99 -I./ruby_headers/193/ -DRUBY_193 -arch x86_64 -c binding_of_caller.c
In file included from binding_of_caller.c:4:
./ruby_headers/193/vm_core.h:32:2: error: "unsupported thread type"
^
./ruby_headers/193/vm_core.h:279:5: error: unknown type name 'rb_global_vm_lock_t'
rb_global_vm_lock_t gvl;
^
./ruby_headers/193/vm_core.h:311:5: error: unknown type name 'rb_event_hook_t'
rb_event_hook_t _event_hooks;
^
./ruby_headers/193/vm_core.h:353:14: error: unknown type name 'rb_data_type_t'
extern const rb_data_type_t ruby_thread_data_type;
^
./ruby_headers/193/vm_core.h:366:9: error: unknown type name 'RUBY_JMP_BUF'
typedef RUBY_JMP_BUF rb_jmpbuf_t;
^
./ruby_headers/193/vm_core.h:426:5: error: unknown type name 'rb_thread_id_t'
rb_thread_id_t thread_id;
^
./ruby_headers/193/vm_core.h:430:5: error: unknown type name 'native_thread_data_t'
native_thread_data_t native_thread_data;
^
./ruby_headers/193/vm_core.h:440:5: error: unknown type name 'rb_thread_lock_t'; did you mean 'pthread_rwlock_t'?
rb_thread_lock_t interrupt_lock;
^~~~~~~~~~~~~~~~
pthread_rwlock_t
/usr/include/pthread.h:99:35: note: 'pthread_rwlock_t' declared here
typedef _darwin_pthread_rwlock_t pthread_rwlock_t;
^
In file included from binding_of_caller.c:4:
./ruby_headers/193/vm_core.h:477:5: error: unknown type name 'rb_event_hook_t'
rb_event_hook_t *event_hooks;
^
./ruby_headers/193/vm_core.h:478:5: error: unknown type name 'rb_event_flag_t'; did you mean 'rb_method_flag_t'?
rb_event_flag_t event_flags;
^~~~~~~~~~~~~~~
rb_method_flag_t
./ruby_headers/193/method.h:26:3: note: 'rb_method_flag_t' declared here
} rb_method_flag_t;
^
In file included from binding_of_caller.c:4:
./ruby_headers/193/vm_core.h:511:1: error: unknown type name 'RUBY_EXTERN'
RUBY_EXTERN VALUE rb_cISeq;
^
./ruby_headers/193/vm_core.h:511:18: error: expected ';' after top level declarator
RUBY_EXTERN VALUE rb_cISeq;
^
;
./ruby_headers/193/vm_core.h:512:1: error: unknown type name 'RUBY_EXTERN'
RUBY_EXTERN VALUE rb_cRubyVM;
^
./ruby_headers/193/vm_core.h:512:18: error: expected ';' after top level declarator
RUBY_EXTERN VALUE rb_cRubyVM;
^
;
./ruby_headers/193/vm_core.h:513:1: error: unknown type name 'RUBY_EXTERN'
RUBY_EXTERN VALUE rb_cEnv;
^
./ruby_headers/193/vm_core.h:513:18: error: expected ';' after top level declarator
RUBY_EXTERN VALUE rb_cEnv;
^
;
./ruby_headers/193/vm_core.h:514:1: error: unknown type name 'RUBY_EXTERN'
RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
^
./ruby_headers/193/vm_core.h:514:18: error: expected ';' after top level declarator
RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
^
;
./ruby_headers/193/vm_core.h:528:5: error: reference to 'VALUE' is ambiguous
VALUE envval; / for GC mark /
^
./ruby_headers/193/vm_core.h:514:13: note: candidate found by name lookup is 'VALUE'
RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
^
/Users/nils/.rvm/rubies/jruby-1.7.4/lib/native/include/ruby/ruby.h:94:19: note: candidate found by name lookup is 'VALUE'
typedef uintptr_t VALUE;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: ** [binding_of_caller.o] Error 1
Gem files will remain installed in /Users/nils/.rvm/gems/jruby-1.7.4@bettertest/bundler/gems/binding_of_caller-25629da62583 for inspection.
Results logged to /Users/nils/.rvm/gems/jruby-1.7.4@bettertest/bundler/gems/binding_of_caller-25629da62583/ext/binding_of_caller/gem_make.out
Nils
When rescuing exceptions in of other instances, I would like to open pry
at the binding of the instance that caused the exception, not where it was rescued. An example:
begin
yield
rescue => e
require 'pry'; yield_binding.pry
end
How to do it?
Hi
OS X ML
Using MacPorts
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12]
Trying to use this with the better_errors gem. The gem installs but trying to start a rails console results in a crash.
dyld: lazy symbol binding failed: Symbol not found: _RUBY_MARK_ENTER
Referenced from: /Users/m/.bundler/gems/binding_of_caller-0.6.8/lib/binding_of_caller.bundle
Expected in: flat namespace
dyld: Symbol not found: _RUBY_MARK_ENTER
Referenced from: /Users/m/.bundler/gems/binding_of_caller-0.6.8/lib/binding_of_caller.bundle
Expected in: flat namespace
Trace/BPT trap: 5
The generated Makefile:
SHELL = /bin/sh
# V=0 quiet, V=1 verbose. other values don't work.
V = 0
Q1 = $(V:1=)
Q = $(Q1:0=@)
n=$(NULLCMD)
ECHO1 = $(V:1=@$n)
ECHO = $(ECHO1:0=@echo)
#### Start of system configuration section. ####
srcdir = .
topdir = /opt/local/include/ruby-1.9.1
hdrdir = /opt/local/include/ruby-1.9.1
arch_hdrdir = /opt/local/include/ruby-1.9.1/$(arch)
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
prefix = $(DESTDIR)/opt/local
rubylibprefix = $(DESTDIR)/opt/local/lib/ruby1.9
exec_prefix = $(prefix)
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
sitehdrdir = $(rubyhdrdir)/site_ruby
rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
vendordir = $(rubylibprefix)/vendor_ruby
sitedir = $(rubylibprefix)/site_ruby
ridir = $(datarootdir)/$(RI_BASE_NAME)
mandir = $(DESTDIR)/opt/local/share/man
localedir = $(datarootdir)/locale
libdir = $(exec_prefix)/lib
psdir = $(docdir)
pdfdir = $(docdir)
dvidir = $(docdir)
htmldir = $(docdir)
infodir = $(datarootdir)/info
docdir = $(datarootdir)/doc/$(PACKAGE)
oldincludedir = $(DESTDIR)/usr/include
includedir = $(prefix)/include
localstatedir = $(prefix)/var
sharedstatedir = $(prefix)/com
sysconfdir = $(prefix)/etc
datadir = $(datarootdir)
datarootdir = $(prefix)/share
libexecdir = $(exec_prefix)/libexec
sbindir = $(exec_prefix)/sbin
bindir = $(exec_prefix)/bin
rubylibdir = $(rubylibprefix)/$(ruby_version)
archdir = $(rubylibdir)/$(arch)
sitelibdir = $(sitedir)/$(ruby_version)
sitearchdir = $(sitelibdir)/$(sitearch)
vendorlibdir = $(vendordir)/$(ruby_version)
vendorarchdir = $(vendorlibdir)/$(sitearch)
NULLCMD = :
CC = /usr/bin/clang
CXX = /usr/bin/clang++
LIBRUBY = $(LIBRUBY_SO)
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
empty =
OUTFLAG = -o $(empty)
COUTFLAG = -o $(empty)
RUBY_EXTCONF_H =
cflags = $(optflags) $(debugflags) $(warnflags)
optflags = -O3
debugflags = -ggdb
warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration
CFLAGS = -fno-common -pipe -O2 -arch x86_64 -fno-common -O0 -std=c99 -I./ruby_headers/193/ -DRUBY_193 $(ARCH_FLAG)
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
DEFS =
CPPFLAGS = -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags) -I/opt/local/include
CXXFLAGS = $(CFLAGS) -pipe -O2
ldflags = -L. -L/opt/local/lib -arch x86_64 -L/opt/local/lib
dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace -L/opt/local/lib
ARCH_FLAG = -arch x86_64
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
LDSHARED = $(CC) -dynamic -bundle
LDSHAREDXX = $(CXX) -dynamic -bundle
AR = ar
EXEEXT =
RUBY_BASE_NAME = ruby
RUBY_INSTALL_NAME = ruby1.9
RUBY_SO_NAME = ruby.1.9.1
arch = x86_64-darwin12
sitearch = $(arch)
ruby_version = 1.9.1
ruby = /opt/local/bin/ruby1.9
RUBY = $(ruby)
RM = rm -f
RM_RF = $(RUBY) -run -e rm -- -rf
RMDIRS = rmdir -p
MAKEDIRS = mkdir -p
INSTALL = /usr/bin/install -c
INSTALL_PROG = $(INSTALL) -m 0755
INSTALL_DATA = $(INSTALL) -m 644
COPY = cp
TOUCH = exit >
#### End of system configuration section. ####
preload =
libpath = . $(libdir) /opt/local/lib
LIBPATH = -L. -L$(libdir) -L/opt/local/lib
DEFFILE =
CLEANFILES = mkmf.log
DISTCLEANFILES =
DISTCLEANDIRS =
extout =
extout_prefix =
target_prefix =
LOCAL_LIBS =
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lobjc
SRCS = binding_of_caller.c
OBJS = binding_of_caller.o
TARGET = binding_of_caller
DLLIB = $(TARGET).bundle
EXTSTATIC =
STATIC_LIB =
BINDIR = $(bindir)
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
TARGET_SO = $(DLLIB)
CLEANLIBS = $(TARGET).bundle
CLEANOBJS = *.o *.bak
all: $(DLLIB)
static: $(STATIC_LIB)
.PHONY: all install static install-so install-rb
.PHONY: clean clean-so clean-rb
clean-rb-default::
clean-rb::
clean-so::
clean: clean-so clean-rb-default clean-rb
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
distclean-rb-default::
distclean-rb::
distclean-so::
distclean: clean distclean-so distclean-rb-default distclean-rb
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
@-$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
realclean: distclean
install: install-so install-rb
install-so: $(RUBYARCHDIR)/$(DLLIB)
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
-$(Q)$(MAKEDIRS) $(@D)
$(INSTALL_PROG) $(DLLIB) $(@D)
clean-static::
-$(Q)$(RM) $(STATIC_LIB)
install-rb: pre-install-rb install-rb-default
install-rb-default: pre-install-rb-default
pre-install-rb: Makefile
pre-install-rb-default: Makefile
pre-install-rb-default:
$(ECHO) installing default binding_of_caller libraries
./.RUBYARCHDIR.time:
$(Q) $(MAKEDIRS) $(RUBYARCHDIR)
$(Q) $(TOUCH) $@
site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb
.SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
.cc.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
.mm.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
.cxx.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
.cpp.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
.C.o:
$(ECHO) compiling $(<)
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
.c.o:
$(ECHO) compiling $(<)
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
.m.o:
$(ECHO) compiling $(<)
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
$(DLLIB): $(OBJS) Makefile
$(ECHO) linking shared-object $(DLLIB)
-$(Q)$(RM) $(@)
$(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
When trying a manual make:
~/.bundler/gems/binding_of_caller-0.6.8/ext/binding_of_caller$ make clean && make
compiling binding_of_caller.c
binding_of_caller.c:40:3: warning: implicit declaration of function 'RUBY_FREE_ENTER' is invalid in C99 [-Wimplicit-function-declaration]
RUBY_FREE_ENTER("binding");
^
binding_of_caller.c:45:3: warning: implicit declaration of function 'RUBY_FREE_LEAVE' is invalid in C99 [-Wimplicit-function-declaration]
RUBY_FREE_LEAVE("binding");
^
binding_of_caller.c:52:3: warning: implicit declaration of function 'RUBY_MARK_ENTER' is invalid in C99 [-Wimplicit-function-declaration]
RUBY_MARK_ENTER("binding");
^
binding_of_caller.c:55:5: warning: implicit declaration of function 'RUBY_MARK_UNLESS_NULL' is invalid in C99 [-Wimplicit-function-declaration]
RUBY_MARK_UNLESS_NULL(bind->env);
^
binding_of_caller.c:62:3: warning: implicit declaration of function 'RUBY_MARK_LEAVE' is invalid in C99 [-Wimplicit-function-declaration]
RUBY_MARK_LEAVE("binding");
^
5 warnings generated.
linking shared-object binding_of_caller.bundle
I've spent some hours looking at this (mostly looking) and am stumped.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.