-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Remove usage of unsafe.Pointer in winc #1556
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
Conversation
Not sure this is the correct fix, but it does fix the problem. |
Deploying with
|
Latest commit: |
847857a
|
Status: | ✅ Deploy successful! |
Preview URL: | https://9367ccce.wails-website.pages.dev |
Branch Preview URL: | https://bugfix-windows-race-detectio.wails-website.pages.dev |
The MakeIntResource which normally is a macro in win32 is very special. It returns a pointer whose value is equal to the int value, so it does not point to an address with the int value but to an address equal to the int value. I think this might be only fixable by changing the return type to an uintptr. But since the recieving method could also be called with an string pointer it would be maybe the best to directly call the loadicon with the uintptr. |
So I think we now return the wrong value. |
@stffabi - yeah, I understand the problem a bit more now. It appears that the use of unsafe pointer and casting to a |
I think we would need to work with a @leaanthony If you would like I could add a proposal to this PR. |
Thanks @stffabi ! I did try changing to uintptr and got reasonably far but it didn't appear to change anything. I was probably doing it wrong |
You have still seen the race error or the missing icon? |
I've added a proposal, with this the icon will be displayed correctly. I wasn't able to test the |
I've just pushed a fix for |
I think there might be still one edge case, the &monitorContainer pointer should be passed as succeeded := w32.EnumDisplayMonitors(dc, nil, syscall.NewCallback(EnumProc), uintptr(unsafe.Pointer(&monitorContainer))) Otherwise go might not know that this pointer is escaping to the syscall and when growing the stack the pointer might become invalid. |
Good catch. I've pushed a commit that I think fixes what you raised. Please review @stffabi 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Just for doc purposes, if one needs to just have the checkptr active without go build -gcflags "all=-N -l -d=checkptr" |
* Add troubleshooting for `Not Found` error (#1586) Issues with Vite's optimizer * Remove usage of unsafe.Pointer in winc (#1556) * Remove usage of unsafe.Pointer * [windows] Remove MakeIntResource and add overloads for Load functions * Fix `EnumProc` race condition. * Refactor `EnumDisplayMonitors` to use `unsafe.Pointer` instead of `uintptr` Co-authored-by: stffabi <stffabi@users.noreply.github.com> * [windows] Fix stack corruption when using ICoreWebView2HttpHeadersCollectionIterator (#1589) The API expects a `BOOL *` with `typedef int BOOL` therefore we need to use a `int32` on the stack. * Docs/better homepage (#1591) * Better carousel width * Learn more button * Learn more button * Fix button/width * Update introduction * Fix outline colour * remove custom css * remove default css * use secondary button * Update sponsors. Improve website for mobile. * v2.0.0-beta.39 * fix docs again (cherry picked from commit 0a9ae0d) * Fix docs for good * Docs FTLOG * Fix docs again! * Fix Varly link * Fix Varly link * Update example for macOS Menu (#1600) * Update example for macOS compatibility Reference #1588 * Add comments, remove duplicates * Add compatibility for Go1.17 (#1605) * v2.0.0-beta.39.2 * [v2] Fix plain template (#1609) * [template] Add missing main.go file to plain template * [dev] If wails could not be find in go.mod output a gracefull error message * Install dev dependencies before starting dev mode (#1615) * Add Show() and Hide() to runtime to show/hide application (#1599) * Add Show() and Hide() to runtime to show/hide application * Fix devserver * Update API docs * Fix container size (#1616) * Update Crowdin configuration file * Update Crowdin configuration file * Update Crowdin configuration file * Bump terser from 4.8.0 to 4.8.1 in /runtime/js (#1625) Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1. - [Release notes](https://github.com/terser/terser/releases) - [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md) - [Commits](https://github.com/terser/terser/commits) --- updated-dependencies: - dependency-name: terser dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump terser from 5.12.0 to 5.14.2 in /website (#1627) Bumps [terser](https://github.com/terser/terser) from 5.12.0 to 5.14.2. - [Release notes](https://github.com/terser/terser/releases) - [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md) - [Commits](https://github.com/terser/terser/commits) --- updated-dependencies: - dependency-name: terser dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Antonio <acheong@student.dalat.org> Co-authored-by: Lea Anthony <lea.anthony@gmail.com> Co-authored-by: stffabi <stffabi@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Compiling with
-race
causes a standard windows app to crash. This fixes that. Potential fix for #1554