Skip to content

Commit ee02769

Browse files
committed
[lwp][rv64] riscv: fix potential signal handler infinite loop
1 parent 2d75100 commit ee02769

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

components/lwp/arch/risc-v/rv64/lwp_gcc.S

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,20 @@ arch_crt_start_umode:
7575
* we handle following things here:
7676
* 1. restoring user mode debug state (not support yet)
7777
* 2. handling thread's exit request
78-
* 3. handling POSIX signal
78+
* 3. handling POSIX signal (skipped for signal quit path)
7979
* 4. restoring user context
8080
* 5. jump to user mode
8181
*/
8282
.global arch_ret_to_user
8383
arch_ret_to_user:
84+
li s0, 1 // flag=1 (normal path)
85+
j arch_ret_to_user_impl
86+
87+
.global arch_signal_quit_ret_to_user
88+
arch_signal_quit_ret_to_user:
89+
li s0, 0 // flag=0 (signal quit path)
90+
91+
arch_ret_to_user_impl:
8492
// TODO: we don't support kernel gdb server in risc-v yet
8593
// so we don't check debug state here and handle debugging bussiness
8694

@@ -90,6 +98,8 @@ arch_ret_to_user:
9098
call sys_exit
9199

92100
1:
101+
// Skip signal handling if coming from arch_signal_quit
102+
beqz s0, ret_to_user_exit
93103
mv a0, sp
94104
call lwp_thread_signal_catch
95105

@@ -119,7 +129,7 @@ arch_signal_quit:
119129

120130
RESTORE_ALL
121131
SAVE_ALL
122-
j arch_ret_to_user
132+
j arch_signal_quit_ret_to_user
123133

124134
/**
125135
* rt_noreturn

0 commit comments

Comments
 (0)