diff options
author | Jeremy Evans <code@jeremyevans.net> | 2020-04-05 12:10:42 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2020-05-22 20:31:23 -0700 |
commit | ad729a1d11c6c57efd2e92803b4e937db0f75252 (patch) | |
tree | 572c79bde61b62de8728ca6d81e3c6dcfbe94d1a /.rspec_parallel | |
parent | fdb31aa7ab1bb1718e57e2e052caff959af3111e (diff) | |
download | ruby-ad729a1d11c6c57efd2e92803b4e937db0f75252.tar.gz |
Fix origin iclass pointer for modules
If a module has an origin, and that module is included in another
module or class, previously the iclass created for the module had
an origin pointer to the module's origin instead of the iclass's
origin.
Setting the origin pointer correctly requires using a stack, since
the origin iclass is not created until after the iclass itself.
Use a hidden ruby array to implement that stack.
Correctly assigning the origin pointers in the iclass caused a
use-after-free in GC. If a module with an origin is included
in a class, the iclass shares a method table with the module
and the iclass origin shares a method table with module origin.
Mark iclass origin with a flag that notes that even though the
iclass is an origin, it shares a method table, so the method table
should not be garbage collected. The shared method table will be
garbage collected when the module origin is garbage collected.
I've tested that this does not introduce a memory leak.
This change caused a VM assertion failure, which was traced to callable
method entries using the incorrect defined_class. Update
rb_vm_check_redefinition_opt_method and find_defined_class_by_owner
to treat iclass origins different than class origins to avoid this
issue.
This also includes a fix for Module#included_modules to skip
iclasses with origins.
Fixes [Bug #16736]
Diffstat (limited to '.rspec_parallel')
0 files changed, 0 insertions, 0 deletions