[#122369] [Ruby Bug#21392] Data classes do not allow overriding #inspect — "austin (Austin Ziegler) via ruby-core" <ruby-core@...>

Issue #21392 has been reported by austin (Austin Ziegler).

8 messages 2025/06/01

[#122411] [Ruby Bug#21396] Set#initialize should call Set#add on items passed in — "tenderlovemaking (Aaron Patterson) via ruby-core" <ruby-core@...>

Issue #21396 has been reported by tenderlovemaking (Aaron Patterson).

12 messages 2025/06/04

[#122506] [Ruby Feature#21435] Kernel#optional as a conditional #then — "Alexander.Senko (Alexander Senko) via ruby-core" <ruby-core@...>

SXNzdWUgIzIxNDM1IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IEFsZXhhbmRlci5TZW5rbyAoQWxleGFu

11 messages 2025/06/10

[#122557] [Ruby Bug#21445] [BUG] push_mark_stack() called for broken object raised since cd9f447be247478d2eb3da985295735cce20cb23 — "yahonda (Yasuo Honda) via ruby-core" <ruby-core@...>

Issue #21445 has been reported by yahonda (Yasuo Honda).

10 messages 2025/06/19

[#122615] [Ruby Misc#21458] Test 'make install'? — "MSP-Greg (Greg L) via ruby-core" <ruby-core@...>

Issue #21458 has been reported by MSP-Greg (Greg L).

11 messages 2025/06/28

[ruby-core:122385] [Ruby Bug#21298] `ObjectSpace.allocation_class_path` returns inconsistent results depending on `TracePoint` state

From: "mame (Yusuke Endoh) via ruby-core" <ruby-core@...>
Date: 2025-06-03 05:47:56 UTC
List: ruby-core #122385
Issue #21298 has been updated by mame (Yusuke Endoh).


Can we go ahead? This will bring incompatibility, so I think this should be fixed by the release. @ktsj @tenderlovemaking 

----------------------------------------
Bug #21298: `ObjectSpace.allocation_class_path` returns inconsistent results depending on `TracePoint` state
https://bugs.ruby-lang.org/issues/21298#change-113545

* Author: mame (Yusuke Endoh)
* Status: Assigned
* Assignee: tenderlovemaking (Aaron Patterson)
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
`ObjectSpace.allocation_class_path` is an API that returns the class of `self` in the context where an object was allocated. However, due to recent optimizations in `Class#new` (#21254), the return value now changes depending on whether `TracePoint` is enabled.

```ruby
require "objspace"

class Foo
  def test
    obj = Object.new
    ObjectSpace.allocation_class_path(obj)
  end
end

ObjectSpace.trace_object_allocations_start

p Foo.new.test #=> 3.4.2: "Class", master: "Foo"
```

Previously, this returned `"Class"` (from the `Class#new` call frame), but in the master branch, the result is now `"Foo"` because that frame is gone.

I am ok for the incompatibility itself because I find the new behavior more intuitive and useful. However, there's an inconsistency: the optimization is disabled when `TracePoint` is enabled, causing the result to revert to the old behavior.

```ruby
p Foo.new.test #=> master: "Foo"

TracePoint.new {}.enable do
  p Foo.new.test #=> master: "Class", expected: "Foo"
end
```

This makes behavior dependent on whether `TracePoint` is enabled, which can lead to confusion.

@ko1 @tenderlovemaking Can we make `ObjectSpace.allocation_class_path` consistently return the class from the `.new` call context, regardless of the `TracePoint` state?

---

I am facing a failure of the following test when code coverage (which uses `TracePoint`) is enabled:

https://github.com/ruby/ruby/blob/e8ad728209ee22136e61054fea74096b49088b8a/test/objspace/test_objspace.rb#L206

As a short-term workaround, I'm considering commenting out this test.



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/


In This Thread

Prev Next