Skip to content

sys/threads: assert on uninitialized mutex/cond handles#489

Open
xvuko wants to merge 1 commit into
masterfrom
xvuko/assert-handle
Open

sys/threads: assert on uninitialized mutex/cond handles#489
xvuko wants to merge 1 commit into
masterfrom
xvuko/assert-handle

Conversation

@xvuko

@xvuko xvuko commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This is first step in improving detection of uninitialized handles. Adding checks to non DEBUG builds needs to be considered, but requires more care before it can be safely adopted.

Motivation and Context

mutexLock is frequently used without checking return value. If mutex create is not invoked then all mutexLock invocations are silently ignored without any sign that locks are never actually held.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a static inline helper function handleIsValid to validate resource handles in sys/threads.c. It also adds assertions using this helper to verify the validity of handles in mutexLock, condWait, and mutexLock2. There are no review comments, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Unit Test Results

9 002 tests   - 1 858   8 350 ✅  - 1 840   50m 36s ⏱️ - 1m 16s
  680 suites +   10     546 💤  -   124 
    1 files   ±    0     106 ❌ +  106 

For more details on these failures, see this check.

Results for commit 460afc1. ± Comparison against base commit 8ff4671.

This pull request removes 1944 and adds 86 tests. Note that renamed tests count towards both.
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.data_in
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.data_in_big
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.data_inout
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.data_inout_big
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.data_out
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.data_out_big
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.in_val
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.invalid_req
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.no_data
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.not_valid_fd
…
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7m7-imxrt117x-evk:phoenix-rtos-tests/ioctl/test-ioctl
phoenix-rtos-tests/ioctl/test-ioctl-nested ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/ioctl/test-ioctl-nested
phoenix-rtos-tests/ioctl/test-ioctl-nested ‑ armv7m7-imxrt117x-evk:phoenix-rtos-tests/ioctl/test-ioctl-nested
phoenix-rtos-tests/libalgo/unit ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/libalgo/unit
phoenix-rtos-tests/libalgo/unit ‑ armv7m7-imxrt117x-evk:phoenix-rtos-tests/libalgo/unit
phoenix-rtos-tests/libc/math ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/libc/math
phoenix-rtos-tests/libc/math ‑ armv7m7-imxrt117x-evk:phoenix-rtos-tests/libc/math
phoenix-rtos-tests/libc/misc ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/libc/misc
phoenix-rtos-tests/libc/misc ‑ armv7m7-imxrt117x-evk:phoenix-rtos-tests/libc/misc
…

♻️ This comment has been updated with latest results.

@xvuko xvuko marked this pull request as ready for review June 25, 2026 17:25
This is first step in improving detection of uninitialized handles.
Adding checks to non DEBUG builds needs to be considered, but requires
more care before it can be safely adopted.
@xvuko xvuko force-pushed the xvuko/assert-handle branch from 41a8cb7 to 460afc1 Compare June 25, 2026 17:26
@xvuko xvuko requested a review from Darchiv June 25, 2026 17:27
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.

1 participant