Skip to content

Commit 4c2ae6e

Browse files
committed
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.
1 parent 0c1ce03 commit 4c2ae6e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/object.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ RBASIC_SET_CLASS(VALUE obj, VALUE klass)
6464
static inline size_t
6565
rb_obj_embedded_size(uint32_t fields_count)
6666
{
67-
#if (defined(RACTOR_CHECK_MODE) && RACTOR_CHECK_MODE) || (defined(GC_DEBUG) && GC_DEBUG)
68-
if (fields_count < 1) fields_count = 1;
69-
#endif
70-
return offsetof(struct RObject, as.ary) + (sizeof(VALUE) * fields_count);
67+
size_t size = offsetof(struct RObject, as.ary) + (sizeof(VALUE) * fields_count);
68+
// Ensure enough room for the heap pointer if this expands
69+
if (size < sizeof(struct RObject)) size = sizeof(struct RObject);
70+
return size;
7171
}
7272
#endif /* INTERNAL_OBJECT_H */

0 commit comments

Comments
 (0)