[ruby-core:93246] [Ruby trunk Feature#15939] Dump symbols reference to their fstr in ObjectSpace.dump()
From:
jean.boussier@...
Date:
2019-06-19 12:52:40 UTC
List:
ruby-core #93246
Issue #15939 has been reported by byroot (Jean Boussier).
----------------------------------------
Feature #15939: Dump symbols reference to their fstr in ObjectSpace.dump()
https://bugs.ruby-lang.org/issues/15939
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Patch: https://github.com/ruby/ruby/pull/2240
Symbols wether they are dynamic or static do hold a reference onto their respective fstring, so it's important to dump these references so that it's possible to see that a String isn't garbage collected because it has an associated Symbol.
Dumping a static Symbol (before):
```
>> puts ObjectSpace.dump(:foobar)
{"type":"SYMBOL", "value":"foobar"}
```
after:
```
>> puts ObjectSpace.dump(:foobar)
{"address":"0x7a210c", "type":"SYMBOL", "value":"foobar", "references":["0x7f8dd482c7d8"], "dynamic": false}
```
Dumping a dynamic Symbol (before):
```
>> puts ObjectSpace.dump("foobar".to_sym)
{"address":"0x7fcdf7042eb0", "type":"SYMBOL", "class":"0x7fcdf70c8628", "frozen":true, "bytesize":6, "value":"foobar", "memsize":40, "flags":{"wb_protected":true}}
```
After:
```
>> puts ObjectSpace.dump("foobar".to_sym)
{"address":"0x7fcdf7042eb0", "type":"SYMBOL", "class":"0x7fcdf70c8628", "frozen":true, "bytesize":6, "value":"foobar", "dynamic":true, "references":["0x7fcdf7042ed8"], "memsize":40, "flags":{"wb_protected":true}}
```
Limitations:
`ObjectSpace.dump_all` rely on `rb_objspace_reachable_objects_from` to list an object's references.
Because of this static symbol "references" are not followed, and as such are invisible in `ObjectSpace.dump_all`.
I'd like to correct it but it's quite more complicated because `rb_objspace_reachable_objects_from` is used by the GC, so I'd need to duplicate that function for `objspace_dump` usage.
So I wouldn't mind some opinion on that before attempting it.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>