Skip to content

Conversation

@guoweikang
Copy link
Contributor

@guoweikang guoweikang commented Dec 29, 2025

Alternative to #94
Closes: #102

…nough.

Closes: #102

Signed-off-by: Weikang Guo <guoweikang@kylinos.cn>
Copilot AI review requested due to automatic review settings December 29, 2025 02:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in SMP (symmetric multiprocessing) scenarios where concurrent access to user memory could cause undefined behavior. The fix changes the ACCESSING_USER_MEM flag from an AtomicBool to an AtomicUsize, implementing reference counting to properly track multiple concurrent accesses.

Key Changes:

  • Replaced boolean flag with atomic counter to support concurrent user memory access tracking
  • Updated access tracking to use fetch_add/fetch_sub for increment/decrement operations
  • Modified the check to compare counter against zero instead of a boolean value

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Weikang Guo <guoweikang@kylinos.cn>
@guoweikang guoweikang force-pushed the gwk/bug_fix_ub_badaddress branch from 0b8b82e to a4adcb6 Compare December 29, 2025 08:22
Signed-off-by: Weikang Guo <guoweikang@kylinos.cn>
@guoweikang guoweikang force-pushed the gwk/bug_fix_ub_badaddress branch from a4adcb6 to 51f8467 Compare December 29, 2025 08:23
@AsakuraMizu AsakuraMizu changed the title BugFix: AccessUserMem flag in SMP scenarios,using atomicbool is not e… fix(smp): move accessing_user_memory into thread data Dec 29, 2025
@AsakuraMizu AsakuraMizu merged commit 05366f4 into main Dec 29, 2025
13 checks passed
@AsakuraMizu AsakuraMizu deleted the gwk/bug_fix_ub_badaddress branch December 29, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] UB aborting on smp=4

3 participants