summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2023-03-17 11:39:35 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2023-03-22 08:46:12 -0700
commit1a9e2d20e2c66933f8eb891a1ee85fae6015fcf1 (patch)
tree281d6536edd16ee9ece6971462f27fcf70151550 /vm.c
parente340eb2106544dffe909104df1ff61236f70f280 (diff)
downloadruby-1a9e2d20e2c66933f8eb891a1ee85fae6015fcf1.tar.gz
Fix shape allocation limits
We can only allocate enough shapes to fit in the shape buffer. MAX_SHAPE_ID was based on the theoretical maximum number of shapes we could have, not on the amount of memory we can actually consume. This commit changes the MAX_SHAPE_ID to be based on the amount of memory we're allowed to consume. Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com>
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/vm.c b/vm.c
index 959966f562..11fc54095b 100644
--- a/vm.c
+++ b/vm.c
@@ -4022,13 +4022,13 @@ Init_vm_objects(void)
#endif
#ifdef HAVE_MMAP
- vm->shape_list = (rb_shape_t *)mmap(NULL, rb_size_mul_or_raise(SHAPE_BITMAP_SIZE * 32, sizeof(rb_shape_t), rb_eRuntimeError),
+ vm->shape_list = (rb_shape_t *)mmap(NULL, rb_size_mul_or_raise(SHAPE_BUFFER_SIZE, sizeof(rb_shape_t), rb_eRuntimeError),
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (vm->shape_list == MAP_FAILED) {
vm->shape_list = 0;
}
#else
- vm->shape_list = xcalloc(SHAPE_BITMAP_SIZE * 32, sizeof(rb_shape_t));
+ vm->shape_list = xcalloc(SHAPE_BUFFER_SIZE, sizeof(rb_shape_t));
#endif
if (!vm->shape_list) {