Prefer th->ec for stack base/size. (#13101)

This commit is contained in:
Samuel Williams 2025-04-17 22:21:51 +09:00 committed by GitHub
parent 6062c904ae
commit c4ae6cb500
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
Notes: git 2025-04-17 13:22:09 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
4 changed files with 86 additions and 6 deletions

24
ext/-test-/stack/stack.c Normal file
View file

@ -0,0 +1,24 @@
#include "ruby.h"
#include "internal/string.h"
static VALUE
stack_alloca_overflow(VALUE self)
{
size_t i = 0;
while (1) {
// Allocate and touch memory to force actual stack usage:
volatile char *stack = alloca(1024);
stack[0] = (char)i;
stack[1023] = (char)i;
i++;
}
return Qnil;
}
void
Init_stack(VALUE klass)
{
rb_define_singleton_method(rb_cThread, "alloca_overflow", stack_alloca_overflow, 0);
}