-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[lwp][rv64] fix potential signal handler infinite loop #10500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以结合下aarch64的情况,查看下这部分如何处理比较合适
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
您好,aarch64和riscv64的处理都是类似的,避免在arch_signal_quit->arch_ret_to_user->lwp_thread_signal_catch 这条调用链上使用lwp_thread_signal_catch 处理信号即可,其余部分保持不变。我尝试了三种可能的修改方案:
1 通过给arch_ret_to_user传入一个额外参数已指示是否需要调用lwp_thread_signal_catch,这种方法可以让线程通过统一的arch_ret_to_user返回用户态。但是所有调用arch_ret_to_user的地方都需要额外传入参数,实现示例链接:https://github.com/RT-Thread/rt-thread/compare/master...eatvector:rt-thread:demo0?expand=1
2 单独针对arch_signal_quit实现一个独立的返回用户态调用接口,与之前提交的方案类似,不过复用了arch_ret_to_user的代码已减少重复代码,这种方案应该是在riscv64和aarch64上最清晰,修改也最少的实现,示例链接:https://github.com/RT-Thread/rt-thread/compare/master...eatvector:rt-thread:demo1?expand=1
3 在线程结构体内部增加额外标记已指示线程是否通过arch_signal_quit返回用户态,如果该标志被设置,则在lwp_thread_signal_catch 不进行任何处理,这种方法所需修改的架构相关内容最少,但是得修改相关的c文件,以及相关结构体,实现示例:https://github.com/RT-Thread/rt-thread/compare/master...eatvector:rt-thread:demo3?expand=1
不知道您认为哪种修改方案更好,或者有其他更好的建议吗?