diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2022-05-05 16:08:24 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2022-05-05 17:37:07 -0400 |
commit | 7448afccb32f78115c05af03421984aa2f2aaf58 (patch) | |
tree | 929ee02d2bfe7adc7b0ccbea58a5192d6113d9b8 /enumerator.c | |
parent | 4acafdf6328cf7ae2b61faa1e309a63a598a7029 (diff) | |
download | ruby-7448afccb32f78115c05af03421984aa2f2aaf58.tar.gz |
Fix potential GC issue while iterating over weak refs
While walking over the list of subclasses for `include` and friends, we
check whether the subclass is a garbage object. After the check, we
allocate objects which might trigger GC and make the subclass garbage,
even though before the allocation the subclass was not garbage. This is
a sort of time-of-check-time-of-use issue.
Fix this by saving the weak reference to a local variable, upgrading it
to a strong reference while we do the allocation. It makes the code look
slightly nicer even if it doesn't fix any runtime issues.
Diffstat (limited to 'enumerator.c')
0 files changed, 0 insertions, 0 deletions