* [ruby-core:121951] [Ruby Bug#21317] Namespaces leak with object IDs
@ 2025-05-09 22:08 fxn (Xavier Noria) via ruby-core
2025-05-10 5:33 ` [ruby-core:121959] " mame (Yusuke Endoh) via ruby-core
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: fxn (Xavier Noria) via ruby-core @ 2025-05-09 22:08 UTC (permalink / raw)
To: ruby-core; +Cc: fxn (Xavier Noria)
Issue #21317 has been reported by fxn (Xavier Noria).
----------------------------------------
Bug #21317: Namespaces leak with object IDs
https://bugs.ruby-lang.org/issues/21317
* Author: fxn (Xavier Noria)
* Status: Open
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Namespaces are not transparent for this program
```ruby
if mod1.object_id == mod2.object_id
mod1.constants == mod2.constants
end
```
because it may fail for `mod1 = Object; mod2 = ns::Object`, which have the same object ID.
--
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:121959] [Ruby Bug#21317] Namespaces leak with object IDs
2025-05-09 22:08 [ruby-core:121951] [Ruby Bug#21317] Namespaces leak with object IDs fxn (Xavier Noria) via ruby-core
@ 2025-05-10 5:33 ` mame (Yusuke Endoh) via ruby-core
2025-05-10 8:11 ` [ruby-core:121963] " fxn (Xavier Noria) via ruby-core
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2025-05-10 5:33 UTC (permalink / raw)
To: ruby-core; +Cc: mame (Yusuke Endoh)
Issue #21317 has been updated by mame (Yusuke Endoh).
Did you actually test the code? `mod1.constants == mod2.constants` returns `true`.
```
$ cat main.rb
ns = Namespace.new
mod1 = Object
mod2 = ns::Object
p mod1 #=> Object
p mod2 #=> Object
p mod1.object_id == mod2.object_id #=> true
p mod1.constants == mod2.constants #=> true
$ RUBY_NAMESPACE=1 ./miniruby main.rb
./miniruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
Object
Object
true
true
```
It's great that you're splitting the ticket and discussing each topic in detail. Thank you for that.
That said, when creating tickets, please make sure to include the test code, what you expected to happen, and what actually happened, in the usual format.
----------------------------------------
Bug #21317: Namespaces leak with object IDs
https://bugs.ruby-lang.org/issues/21317#change-113073
* Author: fxn (Xavier Noria)
* Status: Open
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Namespaces are not transparent for this program
```ruby
if mod1.object_id == mod2.object_id
mod1.constants == mod2.constants
end
```
because it may fail for `mod1 = Object; mod2 = ns::Object`, which have the same object ID.
--
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:121963] [Ruby Bug#21317] Namespaces leak with object IDs
2025-05-09 22:08 [ruby-core:121951] [Ruby Bug#21317] Namespaces leak with object IDs fxn (Xavier Noria) via ruby-core
2025-05-10 5:33 ` [ruby-core:121959] " mame (Yusuke Endoh) via ruby-core
@ 2025-05-10 8:11 ` fxn (Xavier Noria) via ruby-core
2025-05-10 10:12 ` [ruby-core:121979] " fxn (Xavier Noria) via ruby-core
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: fxn (Xavier Noria) via ruby-core @ 2025-05-10 8:11 UTC (permalink / raw)
To: ruby-core; +Cc: fxn (Xavier Noria)
Issue #21317 has been updated by fxn (Xavier Noria).
I suspect this one was an error of mine. I think we can close.
----------------------------------------
Bug #21317: Namespaces leak with object IDs
https://bugs.ruby-lang.org/issues/21317#change-113079
* Author: fxn (Xavier Noria)
* Status: Open
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Namespaces are not transparent for this program
```ruby
if mod1.object_id == mod2.object_id
mod1.constants == mod2.constants
end
```
because it may fail for `mod1 = Object; mod2 = ns::Object`, which have the same object ID.
--
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:121979] [Ruby Bug#21317] Namespaces leak with object IDs
2025-05-09 22:08 [ruby-core:121951] [Ruby Bug#21317] Namespaces leak with object IDs fxn (Xavier Noria) via ruby-core
2025-05-10 5:33 ` [ruby-core:121959] " mame (Yusuke Endoh) via ruby-core
2025-05-10 8:11 ` [ruby-core:121963] " fxn (Xavier Noria) via ruby-core
@ 2025-05-10 10:12 ` fxn (Xavier Noria) via ruby-core
2025-05-10 11:13 ` [ruby-core:121981] " Eregon (Benoit Daloze) via ruby-core
2025-05-10 12:22 ` [ruby-core:121986] " Eregon (Benoit Daloze) via ruby-core
4 siblings, 0 replies; 6+ messages in thread
From: fxn (Xavier Noria) via ruby-core @ 2025-05-10 10:12 UTC (permalink / raw)
To: ruby-core; +Cc: fxn (Xavier Noria)
Issue #21317 has been updated by fxn (Xavier Noria).
@byroot, if you will, I believe this one can be closed too.
----------------------------------------
Bug #21317: Namespaces leak with object IDs
https://bugs.ruby-lang.org/issues/21317#change-113095
* Author: fxn (Xavier Noria)
* Status: Open
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Namespaces are not transparent for this program
```ruby
if mod1.object_id == mod2.object_id
mod1.constants == mod2.constants
end
```
because it may fail for `mod1 = Object; mod2 = ns::Object`, which have the same object ID.
--
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:121981] [Ruby Bug#21317] Namespaces leak with object IDs
2025-05-09 22:08 [ruby-core:121951] [Ruby Bug#21317] Namespaces leak with object IDs fxn (Xavier Noria) via ruby-core
` (2 preceding siblings ...)
2025-05-10 10:12 ` [ruby-core:121979] " fxn (Xavier Noria) via ruby-core
@ 2025-05-10 11:13 ` Eregon (Benoit Daloze) via ruby-core
2025-05-10 12:22 ` [ruby-core:121986] " Eregon (Benoit Daloze) via ruby-core
4 siblings, 0 replies; 6+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-05-10 11:13 UTC (permalink / raw)
To: ruby-core; +Cc: Eregon (Benoit Daloze)
Issue #21317 has been updated by Eregon (Benoit Daloze).
Full reproducer, showing that even though `Object` is the same reference in all namespaces it can have different constants in different namespaces, but only if calling `constants` in that namespace:
```
$ RUBY_NAMESPACE=1 ruby -ve 'ns = Namespace.new; File.write "ns.rb", "O = Object; OC = Object.constants"; ns.require "./ns"; p Object.equal?(ns::O); p Object.constants == ns::OC; p Object.constants == ns::Object.constants'
ruby 3.5.0dev (2025-05-10T07:50:29Z namespace-on-read-.. bd4f57f96b) +PRISM [x86_64-linux]
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for know issues, etc.
true
false
true
```
I think this is expected behavior for Namespace so not sure it's worth reopening.
It does mean that with Namespace even though two objects (specifically core classes and modules) might be equal they are actually different when looked at in different namespaces.
----------------------------------------
Bug #21317: Namespaces leak with object IDs
https://bugs.ruby-lang.org/issues/21317#change-113098
* Author: fxn (Xavier Noria)
* Status: Closed
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Namespaces are not transparent for this program
```ruby
if mod1.object_id == mod2.object_id
mod1.constants == mod2.constants
end
```
because it may fail for `mod1 = Object; mod2 = ns::Object`, which have the same object ID.
--
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:121986] [Ruby Bug#21317] Namespaces leak with object IDs
2025-05-09 22:08 [ruby-core:121951] [Ruby Bug#21317] Namespaces leak with object IDs fxn (Xavier Noria) via ruby-core
` (3 preceding siblings ...)
2025-05-10 11:13 ` [ruby-core:121981] " Eregon (Benoit Daloze) via ruby-core
@ 2025-05-10 12:22 ` Eregon (Benoit Daloze) via ruby-core
4 siblings, 0 replies; 6+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-05-10 12:22 UTC (permalink / raw)
To: ruby-core; +Cc: Eregon (Benoit Daloze)
Issue #21317 has been updated by Eregon (Benoit Daloze).
Seems very related to https://bugs.ruby-lang.org/issues/21322 so let's keep this one closed and discuss there.
----------------------------------------
Bug #21317: Namespaces leak with object IDs
https://bugs.ruby-lang.org/issues/21317#change-113104
* Author: fxn (Xavier Noria)
* Status: Closed
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Namespaces are not transparent for this program
```ruby
if mod1.object_id == mod2.object_id
mod1.constants == mod2.constants
end
```
because it may fail for `mod1 = Object; mod2 = ns::Object`, which have the same object ID.
--
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-05-10 12:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-09 22:08 [ruby-core:121951] [Ruby Bug#21317] Namespaces leak with object IDs fxn (Xavier Noria) via ruby-core
2025-05-10 5:33 ` [ruby-core:121959] " mame (Yusuke Endoh) via ruby-core
2025-05-10 8:11 ` [ruby-core:121963] " fxn (Xavier Noria) via ruby-core
2025-05-10 10:12 ` [ruby-core:121979] " fxn (Xavier Noria) via ruby-core
2025-05-10 11:13 ` [ruby-core:121981] " Eregon (Benoit Daloze) via ruby-core
2025-05-10 12:22 ` [ruby-core:121986] " Eregon (Benoit Daloze) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).