diff options
| author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2025-04-17 22:21:51 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-17 13:21:51 +0000 |
| commit | c4ae6cb5005cfa53be0af466a5619e7455c15744 (patch) | |
| tree | e7ef4d21cab0c9bb4253ca9f00c19c5d73b86e2e /ext/-test-/stack | |
| parent | 6062c904ae2c4d6a9fafb1a0e22841da85892eea (diff) | |
Prefer `th->ec` for stack base/size. (#13101)
Notes
Notes:
Merged-By: ioquatix <samuel@codeotaku.com>
Diffstat (limited to 'ext/-test-/stack')
| -rw-r--r-- | ext/-test-/stack/extconf.rb | 3 | ||||
| -rw-r--r-- | ext/-test-/stack/stack.c | 24 |
2 files changed, 27 insertions, 0 deletions
diff --git a/ext/-test-/stack/extconf.rb b/ext/-test-/stack/extconf.rb new file mode 100644 index 0000000000..d786b15db9 --- /dev/null +++ b/ext/-test-/stack/extconf.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: false +require_relative "../auto_ext.rb" +auto_ext(inc: true) diff --git a/ext/-test-/stack/stack.c b/ext/-test-/stack/stack.c new file mode 100644 index 0000000000..d69ca4da84 --- /dev/null +++ b/ext/-test-/stack/stack.c @@ -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); +} |
