CARVIEW |
Select Language
HTTP/2 200
x-amz-id-2: 50aNXnoVRY6uV7UUXW6MXDRbzrL4MfRPAaqj4yWPbLWMFBJnhLY9AtG1Qs3H7qmR4kZOYU5cnFs=
x-amz-request-id: 4CV99ZTTD95TR4TJ
last-modified: Thu, 15 May 2025 23:41:00 GMT
etag: "4daf0c605571d66e9822d8d33bcdef69"
x-amz-server-side-encryption: AES256
server: AmazonS3
content-encoding: gzip
via: 1.1 varnish, 1.1 varnish
content-type: text/plain; charset=utf-8
accept-ranges: bytes
age: 0
date: Wed, 23 Jul 2025 20:01:48 GMT
x-served-by: cache-tyo11922-TYO, cache-bom-vanm7210073-BOM
x-cache: MISS, MISS
x-cache-hits: 0, 0
x-timer: S1753300908.075510,VS0,VE465
vary: Accept-Encoding
content-length: 737
From: "jhawthorn (John Hawthorn) via ruby-core"
Date: 2025-05-15T23:35:02+00:00
Subject: [ruby-core:122132] [Ruby Bug#21343] Namespace: singleton classes of root namespace leak between namespaces
Issue #21343 has been reported by jhawthorn (John Hawthorn).
----------------------------------------
Bug #21343: Namespace: singleton classes of root namespace leak between namespaces
https://bugs.ruby-lang.org/issues/21343
* Author: jhawthorn (John Hawthorn)
* Status: Open
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Ruby classes all have singleton classes, those singleton classes have singleton classes, and so on with infinite nesting. Since we don't have infinite resources, we create these lazily.
Because of this, only a certain number of singleton classes exist in the root namespace. At a certain depth, mutable singleton classes end up shared between namespaces.
``` ruby
File.write("/tmp/ntest.rb", <<~'RUBY')
p String.singleton_class.singleton_class::Foo
String.singleton_class.singleton_class::Bar = 456
RUBY
String.singleton_class.singleton_class::Foo = 123
ns = Namespace.new
ns.require("/tmp/ntest.rb")
p String.singleton_class.singleton_class::Bar
```
```
RUBY_NAMESPACE=1 ruby nstest2.rb
ruby: warning: Namespace is experimental, and the behavior may change in the future!
See doc/namespace.md for known issues, etc.
123
456
```
--
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/