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

Comments

@gopherbot
Copy link

commented Nov 21, 2018

@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

This comment has been minimized.

Copy link
Author

commented Nov 29, 2018

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

@gopherbot

This comment has been minimized.

Copy link
Author

commented Dec 3, 2018

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

@gopherbot gopherbot closed this Dec 3, 2018

gopherbot pushed a commit that referenced this issue Dec 3, 2018
[release-branch.go1.11] cmd/cgo: use field alignment when setting fie…
…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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.