diff options
author | Fabrice Le Fessant <fabrice@lefessant.net> | 2017-01-17 14:36:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-17 14:36:28 +0100 |
commit | a6329a0c1135a6b6c1e859d4ac65abf50ea40161 (patch) | |
tree | e6c1fc775a1e7747af54212e0277215c04348d66 /otherlibs/systhreads/st_stubs.c | |
parent | 522471d7cb45058b2f2f7bc4dbc2e1f7da56b87a (diff) | |
download | ocaml-a6329a0c1135a6b6c1e859d4ac65abf50ea40161.tar.gz |
Correctly update caml_top_of_stack in systhreads (#996)
Diffstat (limited to 'otherlibs/systhreads/st_stubs.c')
-rw-r--r-- | otherlibs/systhreads/st_stubs.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/otherlibs/systhreads/st_stubs.c b/otherlibs/systhreads/st_stubs.c index 03c370f0b0..e1959febe6 100644 --- a/otherlibs/systhreads/st_stubs.c +++ b/otherlibs/systhreads/st_stubs.c @@ -169,6 +169,7 @@ static void caml_thread_scan_roots(scanning_action action) static inline void caml_thread_save_runtime_state(void) { #ifdef NATIVE_CODE + curr_thread->top_of_stack = caml_top_of_stack; curr_thread->bottom_of_stack = caml_bottom_of_stack; curr_thread->last_retaddr = caml_last_return_address; curr_thread->gc_regs = caml_gc_regs; @@ -197,6 +198,7 @@ static inline void caml_thread_save_runtime_state(void) static inline void caml_thread_restore_runtime_state(void) { #ifdef NATIVE_CODE + caml_top_of_stack = curr_thread->top_of_stack; caml_bottom_of_stack= curr_thread->bottom_of_stack; caml_last_return_address = curr_thread->last_retaddr; caml_gc_regs = curr_thread->gc_regs; @@ -316,7 +318,9 @@ static uintnat caml_thread_stack_usage(void) th != curr_thread; th = th->next) { #ifdef NATIVE_CODE - sz += (value *) th->top_of_stack - (value *) th->bottom_of_stack; + if(th->top_of_stack != NULL && th->bottom_of_stack != NULL && + th->top_of_stack > th->bottom_of_stack) + sz += (value *) th->top_of_stack - (value *) th->bottom_of_stack; #else sz += th->stack_high - th->sp; #endif |