Skip to content

Commit f4cc1b2

Browse files
timcooijmansstoffen
authored andcommitted
cmd/cgo: fix unaligned arguments typedmemmove crash on iOS
Irregularly typedmemmove and bulkBarrierPreWrite crashes on unaligned arguments. By aligning the arguments on 8 bytes this is fixed. Fixes golang#46893 (cherry picked from commit f0cb9ff) (cherry picked from commit 5c35f52)
1 parent 20107e0 commit f4cc1b2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cmd/cgo/out.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
10291029
// string.h for memset, and is also robust to C++
10301030
// types with constructors. Both GCC and LLVM optimize
10311031
// this into just zeroing _cgo_a.
1032-
fmt.Fprintf(fgcc, "\ttypedef %s %v _cgo_argtype;\n", ctype, p.packedAttribute())
1032+
fmt.Fprintf(fgcc, "\ttypedef %s %v __attribute__((aligned(8))) _cgo_argtype;\n", ctype, p.packedAttribute())
10331033
fmt.Fprintf(fgcc, "\tstatic _cgo_argtype _cgo_zero;\n")
10341034
fmt.Fprintf(fgcc, "\t_cgo_argtype _cgo_a = _cgo_zero;\n")
10351035
if gccResult != "void" && (len(fntype.Results.List) > 1 || len(fntype.Results.List[0].Names) > 1) {

0 commit comments

Comments
 (0)