Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TracePoint thread_begin and thread_end events are broken #1321

Closed
headius opened this issue Dec 10, 2013 · 1 comment
Closed

TracePoint thread_begin and thread_end events are broken #1321

headius opened this issue Dec 10, 2013 · 1 comment

Comments

@headius
Copy link
Member

headius commented Dec 10, 2013

The thread_begin and thread_end events used by TracePoint (2.0 feature) do not work properly because they expect execution frames to be available on ThreadContext. For example:

 $ jruby --debug -e "t = TracePoint.new(:thread_begin) {|*a| p a }; t.enable; Thread.new { }.join"
Exception in thread "RubyThread-2: -e:1" java.lang.ArrayIndexOutOfBoundsException: -1
    at org.jruby.runtime.ThreadContext.popFrame(ThreadContext.java:428)
    at org.jruby.runtime.ThreadContext.postTrace(ThreadContext.java:1184)
    at org.jruby.ext.tracepoint.TracePoint$2.eventHandler(TracePoint.java:105)
    at org.jruby.runtime.EventHook.event(EventHook.java:30)
    at org.jruby.Ruby.callEventHooks(Ruby.java:2899)
    at org.jruby.runtime.ThreadContext.trace(ThreadContext.java:648)
    at org.jruby.runtime.ThreadContext.trace(ThreadContext.java:644)
    at org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:98)
    at java.lang.Thread.run(Thread.java:744)

I'm not exactly sure how to properly fire these trace events since they need to happen outside the thread's block, but at that point not all ThreadContext structures necessary for execution have been prepared.

Note also that it fails on the postTrace side, which is strange.

This was discovered while fixing #1318.

@enebo enebo modified the milestone: JRuby 9.0.0.0 Jul 14, 2015
@enebo enebo added this to the JRuby 9.1.8.0 milestone Feb 17, 2017
@enebo
Copy link
Member

enebo commented Feb 17, 2017

Drive-by test and we appear to be sending tracepoints for threads now. The output is not quite the same as MRI but they seem to be happening:

jruby --debug -e 't2 = TracePoint.new(:thread_begin) { |a| puts "START: #{a}"}; t = TracePoint.new(:thread_end) {|a| puts "END: #{a}" }; t2.enable; t.enable; 10.times { Thread.new { } }; sleep 4'

Any other changes needed for output or missing state can become a new issue.

@enebo enebo closed this as completed Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants