[#104740] [Ruby master Feature#18057] Introduce Array#average — ggmichaelgo@...

Issue #18057 has been reported by ggmichaelgo (Michael Go).

14 messages 2021/08/02

[#104774] [Ruby master Bug#18061] Execshield test: libruby.so.N.N.N: FAIL: property-note test because no .note.gnu.property section found — jaruga@...

Issue #18061 has been reported by jaruga (Jun Aruga).

48 messages 2021/08/04

[#104780] [Ruby master Bug#18062] Ruby with enabled LTO segfaults during build — v.ondruch@...

Issue #18062 has been reported by vo.x (Vit Ondruch).

30 messages 2021/08/05

[#104831] [Ruby master Bug#18066] Load did_you_mean eve/error_highlight even with --disable-gems — v.ondruch@...

Issue #18066 has been reported by vo.x (Vit Ondruch).

10 messages 2021/08/07

[#104851] [Ruby master Bug#18073] test/ruby/test_jit.rb: failures "error: invalid use of '__builtin_va_arg_pack ()'" on Ruby 2.7.4 on gcc 4.8.5 on RHEL7 — jaruga@...

Issue #18073 has been reported by jaruga (Jun Aruga).

14 messages 2021/08/09

[#104927] [Ruby master Bug#18077] Marshal.dump(closed_io) raises IOError instead of TypeError — "larskanis (Lars Kanis)" <noreply@...>

Issue #18077 has been reported by larskanis (Lars Kanis).

10 messages 2021/08/16

[#104960] [Ruby master Feature#18083] Capture error in ensure block. — "ioquatix (Samuel Williams)" <noreply@...>

Issue #18083 has been reported by ioquatix (Samuel Williams).

32 messages 2021/08/18

[#105021] [Ruby master Misc#18122] DevelopersMeeting20210916Japan — "mame (Yusuke Endoh)" <noreply@...>

Issue #18122 has been reported by mame (Yusuke Endoh).

12 messages 2021/08/20

[#105069] [Ruby master Bug#18133] LTO: TestGCCompact#test_ast_compacts segfaults on i686 — "vo.x (Vit Ondruch)" <noreply@...>

Issue #18133 has been reported by vo.x (Vit Ondruch).

25 messages 2021/08/25

[#105077] [Ruby master Feature#18136] take_while_after — "zverok (Victor Shepelev)" <noreply@...>

Issue #18136 has been reported by zverok (Victor Shepelev).

21 messages 2021/08/27

[ruby-core:104939] [Ruby master Feature#16889] TracePoint.enable { ... } also activates the TracePoint for other threads, even outside the block

From: "jeremyevans0 (Jeremy Evans)" <noreply@...>
Date: 2021-08-17 05:24:59 UTC
List: ruby-core #104939
Issue #16889 has been updated by jeremyevans0 (Jeremy Evans).


mame (Yusuke Endoh) wrote in #note-7:
> `TracePoint#enable(target: :block)` does not follow events in a called method. Is this really intentional?
> 
> ```
> trace = TracePoint.new(:line) {|tp| p tp }
> 
> def foo
>   1
> end
> 
> trace.enable do
>   foo
> end
> #=>
> # #<TracePoint:line t.rb:8>
> # #<TracePoint:line t.rb:4 in `foo'>
> 
> puts
> 
> trace.enable(target: :block) do
>   foo
> end
> #=>
> # #<TracePoint:line t.rb:17>
> ```
> 
> Note that the second `trace.enable` does not print `#<TracePoint:line t.rb:4 in 'foo'>`.

This matches the behavior of passing the block explicitly and using it as the target:

```ruby
trace = TracePoint.new(:line) {|tp| p tp }

def foo
  1
end

trace.enable do
  foo
end
#=>
# #<TracePoint:line t.rb:8>
# #<TracePoint:line t.rb:4 in `foo'>

puts

pr = proc do
  foo
end

trace.enable(target: pr, &pr) 

#<TracePoint:line t.rb:17>
```

So I think it is expected.  My guess would be while the location of the trace point shows the point of call, it isn't triggered unless the method itself is targeted.  If you target both the method and the block, you get both lines:

```ruby
trace = TracePoint.new(:line) {|tp| p tp }
trace2 = TracePoint.new(:line) {|tp| p tp }

def foo
  1
end

trace.enable do
  foo
end
#=>
# #<TracePoint:line t.rb:8>
# #<TracePoint:line t.rb:4 in `foo'>

puts

pr = proc do
  foo
end

trace2.enable(target: method(:foo)) do
  trace.enable(target: pr, &pr)
end
# #<TracePoint:line -:18>
# #<TracePoint:line -:5 in `foo'>
```

Whether the current behavior of targeted traces is a bug, I'm not sure. If so, it isn't a bug in the `target: :block` support, but a more general issue with targeted traces.

----------------------------------------
Feature #16889: TracePoint.enable { ... } also activates the TracePoint for other threads, even outside the block
https://bugs.ruby-lang.org/issues/16889#change-93303

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
----------------------------------------
```ruby
threads = []
inspects = []
trace = TracePoint.new(:line) do |tp|
  threads << Thread.current
  inspects << tp.inspect
end

done = false
thread = Thread.new do
  Thread.pass until done
end

trace.enable do
  line_event = true
  done = true
  sleep 1
end
thread.join

# Expected only within enable block (lines 14-16)
puts inspects

# Expected just 1
p threads.uniq
```

Results in:
```
$ ruby tpbug.rb
ruby tpbug.rb
#<TracePoint:line@tpbug.rb:14>
#<TracePoint:line@tpbug.rb:15>
#<TracePoint:line@tpbug.rb:16>
#<TracePoint:line@tpbug.rb:10>
[#<Thread:0x00005571134e3340 run>, #<Thread:0x00005571138ac828@tpbug.rb:9 dead>]
```

But I expected:
```
#<TracePoint:line@tpbug.rb:14>
#<TracePoint:line@tpbug.rb:15>
#<TracePoint:line@tpbug.rb:16>
[#<Thread:0x00005571134e3340 run>]
```

Because the RDoc says:
```
If a block is given, the trace will only be enabled within the scope of
the block.
```

For background I'm trying to improve the TracePoint specs in ruby/spec, but they are proving quite unreliable due to this.

@ko1 Thoughts?



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread