Repository navigation
fix(v3/ios): empty string from a bound method no longer crashes the app - #5626
Conversation
The iOS asset response writer guarded the body pointer with 'buf != nil' instead of its length. A bound Go method returning "" produces a zero-length (but non-nil) response body, so '&buf[0]' panicked with index-out-of-range and aborted the Go runtime (SIGABRT). Guard on len(buf) instead — matching the darwin/desktop writers — and pass a nil pointer + length 0 for an empty body (a valid empty NSData on the C side). Reproduced and verified fixed on the iOS simulator.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughIn ChangesiOS Empty-Body Response Writer Fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies" 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. Comment |
There was a problem hiding this comment.
Pull request overview
Fixes an iOS-only crash in the v3 asset server response writer when a bound Go service method returns an empty string, by aligning the iOS response-body pointer guard with the existing desktop behavior.
Changes:
- Update the iOS response writer to guard
&buf[0]by checkinglen(buf) != 0(avoids panic on non-nil, zero-length slices). - Add an unreleased changelog entry documenting the iOS SIGABRT fix and its root cause.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| v3/internal/assetserver/webview/responsewriter_ios.go | Prevents panic on empty response bodies by guarding &buf[0] with a length check. |
| v3/UNRELEASED_CHANGELOG.md | Documents the iOS crash fix in the “Fixed” section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Problem
On iOS, a bound Go service method that returns an empty string immediately crashes the app (SIGABRT / abort trap).
Root cause
The iOS asset response writer (
internal/assetserver/webview/responsewriter_ios.go) guarded the response-body pointer withif buf != nil:A bound method returning
""produces a zero-length but non-nil response body, which passes the!= nilcheck — then&buf[0]panics with index-out-of-range, and the unrecovered panic aborts the Go runtime (SIGABRT). The desktop (darwin) writer already guards correctly withbuf != nil && len(buf) > 0, which is why this was iOS-only.Fix
Guard on length instead of nil (matching the desktop writers). An empty body passes a nil pointer + length 0, which is a valid empty
NSDataon the C side.Verification
Reproduced on the iOS simulator: before the fix, a service method returning
""crashed to the home screen (SIGABRT confirmed in the crash report, faulting thread inside the Go runtime). After the fix, the call returns""correctly (typeof string) and the app runs normally. Non-empty responses are byte-for-byte unchanged.Summary by CodeRabbit