ruby--ruby/internal
Jeremy Evans c745a60634 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 also includes a fix for Module#included_modules to skip
iclasses with origins.

Fixes [Bug #16736]
2020-05-22 07:36:52 -07:00
..
array.h
bignum.h
bits.h
class.h Fix origin iclass pointer for modules 2020-05-22 07:36:52 -07:00
compar.h
compile.h
compilers.h
complex.h
cont.h
dir.h
enc.h
encoding.h
enum.h
enumerator.h
error.h
eval.h
file.h
fixnum.h
gc.h
hash.h
imemo.h
inits.h
io.h
load.h
loadpath.h
math.h
missing.h
mjit.h
numeric.h
object.h
parse.h
proc.h
process.h
random.h
range.h
rational.h
re.h
sanitizers.h
serial.h
signal.h
static_assert.h
string.h
struct.h
symbol.h
thread.h
time.h
transcode.h
util.h
variable.h
vm.h
warnings.h