Skip to content

Fix SystemState_Query atomic load operating on wrong address#3303

Merged
josesimoes merged 1 commit intomainfrom
fix-SystemState
Apr 13, 2026
Merged

Fix SystemState_Query atomic load operating on wrong address#3303
josesimoes merged 1 commit intomainfrom
fix-SystemState

Conversation

@josesimoes
Copy link
Copy Markdown
Member

Description

  • SystemState_Query() on non-Cortex-M0/M0+ targets was atomically loading the local state parameter (an enum index) instead of SystemStates[state], effectively checking whether the state enum value itself was non-zero rather than whether the state was active. This silently broke all system state queries on M3/M4/M7 and similar cores.

Motivation and Context

Fix SystemState_Query atomic load operating on wrong address
(cherry picked from commit 6f158c9)

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dev Containers (changes related with Dev Containers, has no impact on code or features)
  • Dependencies/declarations (update dependencies or assembly declarations and changes associated, has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

(cherry picked from commit 6f158c9)
@josesimoes josesimoes added the Area: Common libs Everything related with common libraries label Apr 13, 2026
@josesimoes josesimoes enabled auto-merge (squash) April 13, 2026 13:54
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 13, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 770583eb-b8f2-4330-9a5d-f049894c1fa5

📥 Commits

Reviewing files that changed from the base of the PR and between 51c4221 and b5b42d1.

📒 Files selected for processing (1)
  • src/HAL/nanoHAL_SystemEvents.c

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Corrected system state query logic to accurately read the correct system states instead of misinterpreting the input parameter. Improves reliability of system state detection across different platform configurations.

Walkthrough

The SystemState_Query function in nanoHAL_SystemEvents.c was corrected to query the system states array instead of reading the function parameter address. The implementation now conditionally branches based on __CM0_CMSIS_VERSION to handle the query appropriately.

Changes

Cohort / File(s) Summary
Bug Fix
src/HAL/nanoHAL_SystemEvents.c
Corrected SystemState_Query to read from SystemStates[state] instead of the input parameter address. Added conditional compilation branch for __CM0_CMSIS_VERSION with separate atomic and direct read paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@josesimoes josesimoes disabled auto-merge April 13, 2026 13:54
@josesimoes josesimoes merged commit 2c4cc68 into main Apr 13, 2026
1 of 5 checks passed
@josesimoes josesimoes changed the title Fix SystemState_Query atomic load operating on wrong address (#3302) Fix SystemState_Query atomic load operating on wrong address Apr 13, 2026
@josesimoes josesimoes deleted the fix-SystemState branch April 13, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Common libs Everything related with common libraries Type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants