Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: nested structure has too much alignment padding [1.11 backport] #28916

Closed
gopherbot opened this issue Nov 21, 2018 · 2 comments
Closed
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge
Milestone

Comments

@gopherbot
Copy link

@ianlancetaylor requested issue #28896 to be considered for backport to the next 1.11 minor release.

@gopherbot Please open an issue to backport to 1.11.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Nov 21, 2018
@gopherbot gopherbot added this to the Go1.11.3 milestone Nov 21, 2018
@andybons andybons added CherryPickApproved Used during the release process for point releases and removed CherryPickCandidate Used during the release process for point releases labels Nov 26, 2018
@gopherbot
Copy link
Author

Change https://golang.org/cl/151778 mentions this issue: [release-branch.go1.11] cmd/cgo: use field alignment when setting field offset

@gopherbot
Copy link
Author

Closed by merging 6fa0ace to release-branch.go1.11.

gopherbot pushed a commit that referenced this issue Dec 3, 2018
…ld offset

The old code ignored the field alignment, and only looked at the field
offset: if the field offset required padding, cgo added padding. But
while that approach works for Go (at least with the gc toolchain) it
doesn't work for C code using packed structs. With a packed struct the
added padding may leave the struct at a misaligned position, and the
inserted alignment, which cgo is not considering, may introduce
additional, unexpected, padding. Padding that ignores alignment is not
a good idea when the struct is not packed, and Go structs are never
packed. So don't ignore alignment.

Updates #28896
Fixes #28916

Change-Id: Ie50ea15fa6dc35557497097be9fecfecb11efd8a
Reviewed-on: https://go-review.googlesource.com/c/150602
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit fbdaa96)
Reviewed-on: https://go-review.googlesource.com/c/151778
TryBot-Result: Gobot Gobot <gobot@golang.org>
@dmitshur dmitshur modified the milestones: Go1.11.3, Go1.11.4 Dec 13, 2018
@golang golang locked and limited conversation to collaborators Dec 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

3 participants