From: shugo@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:72425] [Ruby trunk - Bug #11740] ObjectSpace.each_object exposes internal metaclasses
Date: Tue, 22 Dec 2015 02:36:38 +0000 [thread overview]
Message-ID: <redmine.journal-55718.20151222023637.f5a6a61a91cd4ff5@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11740.20151125102527@ruby-lang.org
Issue #11740 has been updated by Shugo Maeda.
Koichi Sasada wrote:
> Maybe I missed some points.
> Any idea?
You shouldn't hide singleton classes of non-class objects.
```diff
diff --git a/gc.c b/gc.c
index 12be1ea..a574656 100644
--- a/gc.c
+++ b/gc.c
@@ -2400,6 +2400,14 @@ internal_object_p(VALUE obj)
case T_NODE:
case T_ZOMBIE:
break;
+ case T_CLASS:
+ {
+ if (FL_TEST(obj, FL_SINGLETON)) {
+ int rb_singleton_class_has_metaclass_p(VALUE sklass);
+ return RB_TYPE_P(rb_attr_get(obj, id__attached__), T_CLASS) &&
+ rb_singleton_class_has_metaclass_p(obj) == 0;
+ }
+ }
default:
if (!p->as.basic.klass) break;
return 0;
```
----------------------------------------
Bug #11740: ObjectSpace.each_object exposes internal metaclasses
https://bugs.ruby-lang.org/issues/11740#change-55718
* Author: Benoit Daloze
* Status: Assigned
* Priority: Normal
* Assignee: Koichi Sasada
* ruby -v: ruby 2.3.0dev (2015-11-19 trunk 52672) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
ObjectSpace.each_object exposes internal metaclasses and
this might result in assumptions being violated since the metaclass structure is not well preserved.
See the attached script for an example.
The #bla method should always be defined on the metaclass of "klass".
See https://bugs.ruby-lang.org/issues/11360#note-2 as well in which I warned against this problem ;)
---Files--------------------------------
objspace_expose_intern_meta.rb (413 Bytes)
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2015-12-22 2:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-11740.20151125102527@ruby-lang.org>
2015-11-25 10:25 ` [ruby-core:71682] [Ruby trunk - Bug #11740] [Open] ObjectSpace.each_object exposes internal metaclasses eregontp
2015-12-07 7:33 ` [ruby-core:71886] [Ruby trunk - Bug #11740] " ko1
2015-12-16 8:06 ` [ruby-core:72180] " ko1
2015-12-16 14:35 ` [ruby-core:72187] " eregontp
2015-12-17 2:57 ` [ruby-core:72202] " nobu
2015-12-21 10:34 ` [ruby-core:72420] [Ruby trunk - Bug #11740] [Assigned] " ko1
2015-12-22 2:36 ` shugo [this message]
2015-12-24 11:09 ` [ruby-core:72471] [Ruby trunk - Bug #11740] " eregontp
2016-02-03 10:56 ` [ruby-core:73681] [Ruby trunk Bug#11740] " usa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-55718.20151222023637.f5a6a61a91cd4ff5@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).