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: exported cgo types not marked as go:notinheap #41761

Closed
randall77 opened this issue Oct 2, 2020 · 7 comments
Closed

cmd/cgo: exported cgo types not marked as go:notinheap #41761

randall77 opened this issue Oct 2, 2020 · 7 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@randall77
Copy link
Contributor

a.go:

package a

/*
   typedef struct S S;
*/
import "C"

type T struct {
	X *C.S
}

b.go:

package main

/*
   typedef struct S S;
*/
import "C"

import "a"

func main() {
	var x a.T
	_ = (*C.struct_S)(x.X)
}

When trying to build b, we get the error:

./b.go:12:19: cannot convert x.X (type *a._Ctype_struct_S) to type *_Ctype_struct_S:
	_Ctype_struct_S is incomplete (or unallocatable), but a._Ctype_struct_S is not

I think a._Ctype_struct_S should be incomplete as well.

@ianlancetaylor @neild

@randall77
Copy link
Contributor Author

I believe the problem is just that the notinheap annotation does not survive exporting into an object file and importing back. Should be easy to fix.

@randall77
Copy link
Contributor Author

@gopherbot please open a backport to 1.15.

@gopherbot
Copy link

Change https://golang.org/cl/259297 mentions this issue: cmd/compile: export notinheap annotation to object file

@gopherbot
Copy link

Backport issue(s) opened: #41766 (for 1.15).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 6, 2020
@dmitshur dmitshur modified the milestones: Backlog, Go1.16 Oct 6, 2020
@gopherbot
Copy link

Change https://golang.org/cl/265258 mentions this issue: compiler, go/internal/gccgoimporter: export notinheap annotation

gopherbot pushed a commit to golang/gofrontend that referenced this issue Oct 27, 2020
This is the gofrontend version of https://golang.org/cl/259297.
This is required now because that change is in the 1.15.3 release.

This requires changing the go/internal/gccgoimporter package, to skip
the new annotation. This change will need to be ported to the gc and
x/tools repos.

For golang/go#41761

Change-Id: I81d63db7e7c41d168dfa5f1539c063c1c2413568
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/265258
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
@gopherbot
Copy link

Change https://golang.org/cl/265702 mentions this issue: go/internal/gccgoimporter: support notinheap annotation

gopherbot pushed a commit that referenced this issue Oct 27, 2020
The gofrontend has started emitting a notinheap annotation for types
marked go:notinheap.

For #41761

Change-Id: Ic8f7ffc32dbfe98ec09b3d835957f1be8e6c1208
Reviewed-on: https://go-review.googlesource.com/c/go/+/265702
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
@gopherbot
Copy link

Change https://golang.org/cl/265718 mentions this issue: go/internal/gccgoimporter: support notinheap annotation

gopherbot pushed a commit to golang/tools that referenced this issue Oct 27, 2020
Port https://golang.org/cl/265702 from the main Go repo.

Original CL description:
    The gofrontend has started emitting a notinheap annotation for types
    marked go:notinheap.

For golang/go#41761

Change-Id: Ic14ffda4b0c3eef850ad85dbf9af755283a5196b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/265718
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Oct 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants