Repository navigation
Fix threading edge cases on Apple and Zephyr, document async poll locking - #12157
Conversation
wolfSSL_CondSignal dropped and re-took cond->mutex around dispatch_semaphore_signal. A failure of either step returned with the mutex not held, breaking the CondStart/CondEnd contract. The signal never blocks so there is no need to release the mutex.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the threading fixes and async callback locking documentation.
No open issues 🎉
What changed in this PR
This PR fixes Apple and Zephyr threading edge cases in wolfSSL’s portability layer and documents existing async callback locking requirements.
Changes:
- Keep the Apple condition-variable mutex held while signaling.
- Capture the Zephyr heap hint once so thread allocations and cleanup use the same heap.
- Document async poll callback restrictions in headers and English/Japanese API documentation, without changing locking behavior.
| File | Description |
|---|---|
wolfssl/wolfcrypt/types.h |
Store the allocation heap in Zephyr’s thread structure. |
wolfssl/wolfcrypt/mem_track.h |
Reuse one heap hint throughout Zephyr stack-size checks. |
wolfssl/wolfcrypt/cryptocb.h |
Document that async poll callbacks run with the queue lock held. |
wolfcrypt/src/wc_port.c |
Preserve Zephyr heap pairing and Apple mutex ownership during signaling. |
doc/dox_comments/header_files/cryptocb.h |
Explain async callback locking restrictions in English. |
doc/dox_comments/header_files-ja/cryptocb.h |
Add equivalent locking guidance in Japanese. |
Review effort: Balanced
|
yosuke-wolfssl
left a comment
There was a problem hiding this comment.
JA doc is clear and easy to understand for me.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12157
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): doc/dox_comments/header_files-ja/cryptocb.h, doc/dox_comments/header_files/cryptocb.h
Coverage: 4 of 4 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
The event queue poll has always held queue->lock across the device poll, for QAT, Nitrox and the software backend. The crypto callback poll follows the same model. Holding the lock is intended: it serializes the poll callbacks of one queue. State the rule a handler has to follow instead of changing the locking.
wolfSSL_NewThread and wolfSSL_JoinThread both read the global wolfsslThreadHeapHint. Changing it between the two frees memory to the wrong heap. The hint is meant to be set once at startup, so state that instead of supporting a change.
25a231b to
8a96986
Compare
|
@philljj addressed |
|
Retest this please. (single PRB subtest hiccup) |
wolfSSL_CondSignalno longer drops and re-takescond->mutexarounddispatch_semaphore_signal. Failure of either step could return with the mutex not held, which broke the CondStart/CondEnd contract. The signal never blocks, so releasing the mutex is unnecessary (F-11183).wolfSSL_NewThreadandwolfSSL_JoinThreadeach read the globalwolfsslThreadHeapHintseparately, so a change between the two could free the thread struct and stack to the wrong heap. The hint is now read once and stored inTHREAD_TYPE. The stack size check inmem_track.hgets the same treatment (F-15097).queue->lockacross the device poll (QAT, Nitrox and the software backend), and that the crypto callback poll follows the same model. The lock is intentional because it serializes the poll callbacks of one queue, so the locking is unchanged and the docs now state the rule a handler must follow (F-12216).