summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2025-04-17 22:21:51 +0900
committerGitHub <noreply@github.com>2025-04-17 13:21:51 +0000
commitc4ae6cb5005cfa53be0af466a5619e7455c15744 (patch)
treee7ef4d21cab0c9bb4253ca9f00c19c5d73b86e2e /thread_pthread.c
parent6062c904ae2c4d6a9fafb1a0e22841da85892eea (diff)
Prefer `th->ec` for stack base/size. (#13101)
Notes
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 993437f02b..195fe69948 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -3149,8 +3149,12 @@ ruby_stack_overflowed_p(const rb_thread_t *th, const void *addr)
const size_t water_mark = 1024 * 1024;
STACK_GROW_DIR_DETECTION;
+ if (th) {
+ size = th->ec->machine.stack_maxsize;
+ base = (char *)th->ec->machine.stack_start - STACK_DIR_UPPER(0, size);
+ }
#ifdef STACKADDR_AVAILABLE
- if (get_stack(&base, &size) == 0) {
+ else if (get_stack(&base, &size) == 0) {
# ifdef __APPLE__
if (pthread_equal(th->nt->thread_id, native_main_thread.id)) {
struct rlimit rlim;
@@ -3161,15 +3165,11 @@ ruby_stack_overflowed_p(const rb_thread_t *th, const void *addr)
# endif
base = (char *)base + STACK_DIR_UPPER(+size, -size);
}
- else
#endif
- if (th) {
- size = th->ec->machine.stack_maxsize;
- base = (char *)th->ec->machine.stack_start - STACK_DIR_UPPER(0, size);
- }
else {
return 0;
}
+
size /= RUBY_STACK_SPACE_RATIO;
if (size > water_mark) size = water_mark;
if (IS_STACK_DIR_UPPER()) {