Repository navigation
Bug 1718838 - Don't call pthread_equal() on possibly-invalid thread IDs - #66
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66 +/- ##
==========================================
+ Coverage 42.20% 48.91% +6.70%
==========================================
Files 70 93 +23
Lines 12071 17828 +5757
Branches 2261 2261
==========================================
+ Hits 5095 8720 +3625
- Misses 6126 8687 +2561
+ Partials 850 421 -429
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Valid thread handles should retain POSIX comparison semantics, and the invalid-owner path needs regression coverage.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Prevents undefined behavior when comparing uninitialized pthread owner IDs.
Changes:
- Adds a safe thread-ID comparison helper.
- Updates lock, monitor, and thread comparisons.
| File | Description |
|---|---|
pr/src/pthreads/ptthread.c |
Uses the new comparison helper. |
pr/src/pthreads/ptsynch.c |
Adds the helper and updates owner comparisons. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
a18c3b6 to
d555b4c
Compare
nspr4 backport check
Alone: cherry-picks onto nspr4 by itself. In order: cherry-picks onto nspr4 after the earlier commits, skipping any that conflict. Verdict: backportable |
PR_GetMonitorEntryCount() could pass an unset mon->owner to pthread_equal(), which is UB. Only compare when entryCount != 0. https://bugzilla.mozilla.org/show_bug.cgi?id=1718838 From NetBSD pkgsrc.
d555b4c to
6d85421
Compare
|
@sylvestre thanks, that really simplified the diff :-) |


lock/mon
ownerfields can be zero-initialized;pthread_equal()on that is UB. Addpt_pthread_equal(): fall back to==only for the invalid sentinel, else delegate to realpthread_equal(). Used whereverpthread_equal()compared a possibly-unset owner, inptsynch.candptthread.c.https://bugzilla.mozilla.org/show_bug.cgi?id=1718838
From NetBSD pkgsrc.