@@ -687,6 +687,23 @@ sp_in_stk_seg(uintptr_t sp, stk_seg *stk) {
687
687
return (uintptr_t )stk->data <= sp && sp <= stk->end ;
688
688
}
689
689
690
+ struct reset_args {
691
+ rust_task *task;
692
+ uintptr_t sp;
693
+ };
694
+
695
+ void
696
+ reset_stack_limit_on_c_stack (reset_args *args) {
697
+ rust_task *task = args->task ;
698
+ uintptr_t sp = args->sp ;
699
+ while (!sp_in_stk_seg (sp, task->stk )) {
700
+ task->del_stack ();
701
+ A (task->thread , task->stk != NULL ,
702
+ " Failed to find the current stack" );
703
+ }
704
+ task->record_stack_limit ();
705
+ }
706
+
690
707
/*
691
708
Called by landing pads during unwinding to figure out which
692
709
stack segment we are currently running on, delete the others,
@@ -695,12 +712,12 @@ through __morestack).
695
712
*/
696
713
void
697
714
rust_task::reset_stack_limit () {
715
+ I (thread, on_rust_stack ());
698
716
uintptr_t sp = get_sp ();
699
- while (!sp_in_stk_seg (sp, stk)) {
700
- del_stack ();
701
- A (thread, stk != NULL , " Failed to find the current stack" );
702
- }
703
- record_stack_limit ();
717
+ // Have to do the rest on the C stack because it involves
718
+ // freeing stack segments, logging, etc.
719
+ reset_args ra = {this , sp};
720
+ call_on_c_stack (&ra, (void *)reset_stack_limit_on_c_stack);
704
721
}
705
722
706
723
void
0 commit comments