Comments (7)
We can handle simple cases, but what if we import some other package that has type MyUnsafePointer = unsafe.Pointer
and then refer to it as otherpkg.MyUnsafePointer(x)
? Is it better to have some type aliases work and some not, or is it better to not try to make type aliases work? It's not clear to me which approach is less confusing.
from go.
This seems to me a cmd/cgo
issue, not the runtime.
cgo does not recorgnize that up(&x.self)
is a type conversion, so it emits the cgo check pointer call with up(&x.self)
as argument, not &x.self
in case of unsafe.Pointer(&x.self)
.
from go.
I don't know how to fix this except to do full type checking on the cgo input file, which is difficult as we currently expect the type checker to run on cgo output, not cgo input. Fixing this correctly may require something like #16623, which is a lot of work.
from go.
@ianlancetaylor We could probably record type alias only, something like map[string]string{"up": "unsafe.Pointer"}
, then the p.isType
check can correctly recognize and stripe the type conversion.
from go.
A related previous issue was #57926, in which users exploited the desugaring of cgo to declare methods on types that appear to belong to package C: func (C.T) method() {}
The resolution was to use syntactic heuristics to try to reject it, so that we at least make clear that this is not allowed, even if we can't detect it in general (e.g. in the presence of aliasing) without type checking, which is infeasible for the reason @ianlancetaylor noted.
from go.
@ianlancetaylor Assigned it to you for now, please feel free to update.
from go.
Thanks, I'm unassigning as I have no plans to work on this.
from go.
Related Issues (20)
- x/tools/gopls: add control flow token support HOT 2
- x/net/http2: requests experience excessive time delays when encountering network errors HOT 1
- net/http: Inconsistent output with req.URL.RequestURI() HOT 1
- cmd/compile: different results from runtime.Caller HOT 4
- proposal: x/sys/unix: add MmapPtr/MunmapPtr HOT 1
- runtime: unexpected return pc for github.com/pact-foundation/pact-go HOT 4
- x/net/http2: h2c requests can't be sent when *http.Request.Close is true HOT 1
- x/crypto/ssh: new API to allow user to get channel close event HOT 1
- wasi: net implement sockets HOT 7
- x/tools/gopls/internal/test/marker: tests are timing out on freebsd HOT 1
- proposal: crypto/x509: automatically generate serial if template SerialNumber is nil HOT 1
- os: os.Create & os.OpenFile both not creating .json file HOT 7
- x/telemetry/config: add govulncheck counters
- flag: compiler not picking up on redefined flags HOT 4
- security: fix CVE-2024-24790 HOT 2
- security: fix CVE-2024-24790 [1.21 backport]
- security: fix CVE-2024-24790 [1.22 backport]
- cmd/compile: generic type alias useable without instantiation HOT 2
- x/tools/gopls: spurious 'unused write' in package reflect HOT 4
- cmd/compile: inconsistent quoting of program text HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go.