Check MACH_PORT_VALID on return from pthread_mach_thread_np
:scroll: Description
pthread_mach_thread_np can return invalid values so check for those and return nullptr from ThreadHandle. That means changing the call sites for ThreadHandle::current() to check for a null pointer value.
:bulb: Motivation and Context
We don't have a solid repro for https://github.com/getsentry/sentry-cocoa/issues/3354 but this is one of the potential causes. In any case it doesn't hurt to add the check.
:green_heart: How did you test it?
Run tests
:pencil: Checklist
You have to check all boxes before merging:
- [X] I reviewed the submitted code.
- [ ] I added tests to verify the changes.
- [ ] No new PII added or SDK only sends newly added PII if
sendDefaultPIIis enabled. - [ ] I updated the docs if needed.
- [ ] Review from the native team if needed.
- [ ] No breaking change or entry added to the changelog.
- [ ] No breaking change for hybrid SDKs or communicated to hybrid SDKs.
:crystal_ball: Next steps
Codecov Report
Attention: Patch coverage is 81.13208% with 10 lines in your changes missing coverage. Please review.
Project coverage is 91.165%. Comparing base (
1734d1b) to head (6fac4d6). Report is 343 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #3520 +/- ##
=============================================
+ Coverage 89.241% 91.165% +1.923%
=============================================
Files 529 609 +80
Lines 57780 47846 -9934
Branches 20687 0 -20687
=============================================
- Hits 51564 43619 -7945
+ Misses 5300 4227 -1073
+ Partials 916 0 -916
| Files | Coverage Δ | |
|---|---|---|
| Sources/Sentry/PrivateSentrySDKOnly.mm | 90.714% <100.000%> (+3.558%) |
:arrow_up: |
| Sources/Sentry/SentryThreadHandle.cpp | 62.727% <100.000%> (-6.504%) |
:arrow_down: |
| Sources/Sentry/SentryTransactionContext.mm | 100.000% <100.000%> (ø) |
|
| ...yCrash/Recording/Monitors/SentryCrashMonitorType.c | 0.000% <ø> (ø) |
|
| ...entryCrash/Recording/Tools/SentryCrashSignalInfo.c | 100.000% <ø> (ø) |
|
| ...sts/SentryProfilerTests/SentryThreadHandleTests.mm | 95.789% <100.000%> (+2.932%) |
:arrow_up: |
| Tests/SentryTests/SentryCrash/CrashReport.swift | 100.000% <100.000%> (+6.666%) |
:arrow_up: |
| Tests/SentryTests/SentryInterfacesTests.m | 100.000% <100.000%> (ø) |
|
| ...rding/Monitors/SentryCrashMonitor_CPPException.cpp | 20.408% <0.000%> (-10.223%) |
:arrow_down: |
| Tests/SentryProfilerTests/SentryBacktraceTests.mm | 95.744% <88.888%> (+0.939%) |
:arrow_up: |
| ... and 2 more |
... and 607 files with indirect coverage changes
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 1734d1b...6fac4d6. Read the comment docs.
Performance metrics :rocket:
| Plain | With Sentry | Diff | |
|---|---|---|---|
| Startup time | 1208.50 ms | 1221.08 ms | 12.58 ms |
| Size | 21.58 KiB | 671.08 KiB | 649.50 KiB |
Baseline results on branch: main
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 52e491237a32581d5dfebccd918d7a8b2f278566 | 1216.25 ms | 1226.69 ms | 10.44 ms |
| 742d4b693cfd3cf2b7b1d62930d16daaf505d367 | 1230.41 ms | 1247.23 ms | 16.83 ms |
| 297f4604214bd658bd0a752adfcbbd2e41bd85e2 | 1234.81 ms | 1255.27 ms | 20.45 ms |
| becc941ddc9156db1364a0ac09c97b027ffcc774 | 1221.90 ms | 1240.37 ms | 18.47 ms |
| 340fb468c2c7baa329a34974896ad26ccb9f31ff | 1224.60 ms | 1239.27 ms | 14.67 ms |
| 3297d6e29cd37151f68e9c605aea8b44e5e432cb | 1195.69 ms | 1212.35 ms | 16.65 ms |
| 0d32275107b8a0160580f99b52ddbcee94196ddb | 1215.31 ms | 1240.19 ms | 24.88 ms |
| 4d3df92302ef894ca2de1787295d7d1417b49649 | 1218.27 ms | 1248.30 ms | 30.03 ms |
| b15521ec4775f623b296e1fca558ffac46447bb8 | 1224.44 ms | 1251.13 ms | 26.68 ms |
| e5dcbd5e2d4fff30521db1ad3c569ee287f5b7a2 | 1223.47 ms | 1243.90 ms | 20.43 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 52e491237a32581d5dfebccd918d7a8b2f278566 | 21.58 KiB | 418.14 KiB | 396.56 KiB |
| 742d4b693cfd3cf2b7b1d62930d16daaf505d367 | 21.58 KiB | 546.20 KiB | 524.62 KiB |
| 297f4604214bd658bd0a752adfcbbd2e41bd85e2 | 21.58 KiB | 629.83 KiB | 608.24 KiB |
| becc941ddc9156db1364a0ac09c97b027ffcc774 | 21.58 KiB | 419.82 KiB | 398.24 KiB |
| 340fb468c2c7baa329a34974896ad26ccb9f31ff | 21.58 KiB | 418.78 KiB | 397.20 KiB |
| 3297d6e29cd37151f68e9c605aea8b44e5e432cb | 21.58 KiB | 418.44 KiB | 396.86 KiB |
| 0d32275107b8a0160580f99b52ddbcee94196ddb | 22.84 KiB | 403.14 KiB | 380.29 KiB |
| 4d3df92302ef894ca2de1787295d7d1417b49649 | 22.85 KiB | 413.45 KiB | 390.60 KiB |
| b15521ec4775f623b296e1fca558ffac46447bb8 | 21.58 KiB | 573.18 KiB | 551.60 KiB |
| e5dcbd5e2d4fff30521db1ad3c569ee287f5b7a2 | 22.85 KiB | 414.09 KiB | 391.24 KiB |
@armcknight, I guess after resolving the conflicts, I can review this?