Fix Kernel#set_trace_func invocation after native Java EventHooks#2604
Closed
gsamokovarov wants to merge 1 commit intojruby:masterfrom
Closed
Fix Kernel#set_trace_func invocation after native Java EventHooks#2604gsamokovarov wants to merge 1 commit intojruby:masterfrom
gsamokovarov wants to merge 1 commit intojruby:masterfrom
Conversation
Hello,
Currently, registering plain Ruby `Kernel#set_trace_func` after native
extensions EventHooks fails with:
```
bug.rb:2 warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
Ruby.java:3058:in `removeEventHook': java.lang.ArrayIndexOutOfBoundsException: 0
from Ruby.java:3066:in `setTraceFunction'
from RubyKernel.java:1206:in `set_trace_func'
from RubyKernel$INVOKER$s$1$0$set_trace_func.gen:-1:in `call'
from JavaMethod.java:364:in `call'
from CachingCallSite.java:317:in `cacheAndCall'
from CachingCallSite.java:167:in `call'
from Interpreter.java:293:in `processCall'
from Interpreter.java:550:in `interpret'
from Interpreter.java:617:in `INTERPRET_ROOT'
from Interpreter.java:112:in `execute'
from Interpreter.java:28:in `execute'
from IRTranslator.java:39:in `execute'
from Ruby.java:855:in `runInterpreter'
from Ruby.java:863:in `runInterpreter'
from Ruby.java:759:in `runNormally'
from Ruby.java:564:in `runFromMain'
from Main.java:405:in `doRunFromMain'
from Main.java:300:in `internalRun'
from Main.java:227:in `run'
from Main.java:199:in `main'
```
I have a small reproduction script, which uses `Coverage`'s native
EventHook, however the problem is present in custom extensions that
implement EventHooks themselves as well.
Here is the script:
```ruby
require 'coverage'
Coverage.start
set_trace_func proc { |*args| p args }
```
I'm not sure whether my current solution is good enough, since I don't
know if the bargain with removeEventHook is to always find the previous
eventHook before, however it does prevent the crash in my tests.
Hope it helps!
e8f6556 to
6eee5e4
Compare
Member
|
I totally rewrote this method because it had a second issue in addition to the AIIOB (see #2903). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
Currently, registering plain Ruby
Kernel#set_trace_funcafter nativeextensions EventHooks fails with:
I have a small reproduction script, which uses
Coverage's nativeEventHook, however the problem is present in custom extensions that
implement EventHooks themselves as well.
Here is the script:
I'm not sure whether my current solution is good enough, since I don't
know if the bargain with removeEventHook is to always find the previous
eventHook before, however it does prevent the crash in my tests.
Hope it helps!