Skip to content

Use runtime.Pin to remove unsafe code #74

@jchv

Description

@jchv

Time has passed and now it should be trivially possible to fix our broken reliance on pointers not moving, as runtime.Pin eventually did arrive in Go 1.21.

https://github.com/jchv/go-webview2/blob/master/pkg/edge/chromium.go#L49-L59

We probably just need one pinner for all of the handlers. One open question is when to execute the unpin; a finalizer might be the safest bet. (In the future, it may be done more efficiently using runtime.AddCleanup, but doing that would require depending on Go 1.24.0 or higher, which is not desirable yet.)

I'm considering this a bug since the code is relying on behavior that is explicitly not guaranteed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions