mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 04:55:21 +02:00
Prefer th->ec
for stack base/size. (#13101)
This commit is contained in:
parent
6062c904ae
commit
c4ae6cb500
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
24
ext/-test-/stack/stack.c
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue