Skip to content

fix: ARM64 HFA return checkptr crash + 9-16B struct corruption (v0.6.3) - #68

Merged
kolkov merged 1 commit into
mainfrom
fix/arm64-hfa-checkptr
Aug 1, 2026
Merged

fix: ARM64 HFA return checkptr crash + 9-16B struct corruption (v0.6.3)#68
kolkov merged 1 commit into
mainfrom
fix/arm64-hfa-checkptr

Conversation

@kolkov

@kolkov kolkov commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix handleHFAReturn checkptr crash: (*[4]float64)(rvalue) oversized for 2-3 element HFAs (CGSize/CGPoint = 16 bytes, cast = 32 bytes). go test -race crashed with "converted pointer straddles multiple allocations"
  • Fix (*[2]uint64)(rvalue) for 9-16B struct returns: wrote 8 full bytes for hi word when struct < 16 bytes. Proactive fix — checkptr doesn't catch this (GC pads to 16) but packed C structs could corrupt
  • Both fixes use unsafe.Add / copy per-element, matching AMD64 patterns

Test plan

  • go build ./... — clean
  • go test ./... — all pass
  • ARM64 cross-compile + vet clean
  • golangci-lint: 0 issues
  • TestHandleHFAReturn_Checkptr + TestHandleHFAReturn_Float32 added
  • CI green

Closes #67

…loses #67)

handleHFAReturn cast (*[4]float64)(rvalue) was oversized for 2-3 element
HFAs — checkptr detected the cast spanning beyond the rvalue allocation.
Fix: per-element writes via unsafe.Add, matching existing single-element
pattern.

Also fix (*[2]uint64)(rvalue) for 9-16B struct returns — wrote 8 full
bytes for hi word even when struct < 16 bytes. Fix: copy with exact
remaining size, matching AMD64 pattern. Proactive — checkptr doesn't
catch this (GC pads to 16) but packed C structs could corrupt.
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kolkov
kolkov merged commit a97955c into main Aug 1, 2026
15 checks passed
@kolkov
kolkov deleted the fix/arm64-hfa-checkptr branch August 1, 2026 20:05
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.

bug: ARM64 handleHFAReturn crashes under -race (checkptr) — oversized array cast

1 participant