diff options
| author | John Hawthorn <john@hawthorn.email> | 2026-04-09 11:48:57 -0700 |
|---|---|---|
| committer | John Hawthorn <john@hawthorn.email> | 2026-04-09 17:39:58 -0700 |
| commit | 4c2ae6e2adb40c39276cac860658495f9fa7d967 (patch) | |
| tree | 39154408d02b8976b22abd859d6673ab29eef5d1 | |
| parent | 0c1ce03b8c8431d27bc45f88541929881edd4e3e (diff) | |
Always ensure room in rb_obj_embedded_size
Although the issue only occurred on debug builds, we should always be
requesting a size large enough to fit the object when it expands to the
heap, rather than just hoping the GC provides enough room.
| -rw-r--r-- | internal/object.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/object.h b/internal/object.h index 3cf58d55d9..99aa1f524b 100644 --- a/internal/object.h +++ b/internal/object.h @@ -64,9 +64,9 @@ RBASIC_SET_CLASS(VALUE obj, VALUE klass) static inline size_t rb_obj_embedded_size(uint32_t fields_count) { -#if (defined(RACTOR_CHECK_MODE) && RACTOR_CHECK_MODE) || (defined(GC_DEBUG) && GC_DEBUG) - if (fields_count < 1) fields_count = 1; -#endif - return offsetof(struct RObject, as.ary) + (sizeof(VALUE) * fields_count); + size_t size = offsetof(struct RObject, as.ary) + (sizeof(VALUE) * fields_count); + // Ensure enough room for the heap pointer if this expands + if (size < sizeof(struct RObject)) size = sizeof(struct RObject); + return size; } #endif /* INTERNAL_OBJECT_H */ |
