Skip to content

Instantly share code, notes, and snippets.

@shirosaki
Created May 7, 2013 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirosaki/5536902 to your computer and use it in GitHub Desktop.
Save shirosaki/5536902 to your computer and use it in GitHub Desktop.
Set stack_start of rb_thread_t in ruby_init_stack()
diff --git a/thread_pthread.c b/thread_pthread.c
index eb98024..30ca276 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -45,6 +45,7 @@ static void native_cond_wait(rb_thread_cond_t *cond, pthread_mutex_t *mutex);
static void native_cond_initialize(rb_thread_cond_t *cond, int flags);
static void native_cond_destroy(rb_thread_cond_t *cond);
static void rb_thread_wakeup_timer_thread_low(void);
+static int native_thread_init_stack(rb_thread_t *th);
static pthread_t timer_thread_id;
#define RB_CONDATTR_CLOCK_MONOTONIC 1
@@ -690,6 +691,12 @@ ruby_init_stack(volatile VALUE *addr
native_main_thread.stack_maxsize = 0; /* unknown */
}
}
+ {
+ rb_thread_t *th = GET_THREAD();
+ if (th && pthread_equal(th->thread_id, native_main_thread.id)) {
+ native_thread_init_stack(th);
+ }
+ }
}
#define CHECK_ERR(expr) \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment