Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make rb_objspace_garbage_object_p()=true on non-heap pointers
In rare situations, by the time vm_ccs_free() runs, the stale cc pointer might point to a heap page that has been freed a long time ago and is no longer part of the active GC heap anymore. Previously we'd try to read and write through the stale pointer anyways, which caused use-after-free crashes. Surely other callers are at least fine with this change, if not also avoid bugs in similar situations. if (!rb_objspace_garbage_object_p((VALUE)cc) && IMEMO_TYPE_P(cc, imemo_callcache) && // <-- Previously UAF cc->klass == klass) { Not changing rb_gc_impl_garbage_object_p(), since the GC always work within the confines of its heap already, so no need to check there.
- Loading branch information