timrobertsdev / hotcorners

A small hot corners implementation for Windows 10/11
GNU General Public License v3.0
29 stars 2 forks source link

Release build doesn't seem to work #13

Closed avi-cenna closed 3 months ago

avi-cenna commented 3 months ago

This is a nice tool, but the release build doesn't seem to work for some reason.

I did both cargo build and cargo build --release. When I ran the release executable with start target/release/hotcorners.exe nothing happens when I move my mouse to the top left corner. However, when I run the debug build with start target/debug/hotcorners.exe it works as expected.

timrobertsdev commented 3 months ago

Interesting. Reproduced on my machines. Thanks for reporting, I'll have to look into this.

Release optimizations must be stripping something out, since everything works as expected with opt-level = 0.

further edit: When release optimizations are enabled, we hit a stack buffer overflow inside of the hook function, but when they're disabled we don't. fun.

timrobertsdev commented 3 months ago

Even more fun, anything above opt-level = 0 seems to be causing incorrect parameters being passed to our callback function that gets registered with Windows.

edit: Starts appearing in Rust 1.78. The n_code argument seems to not be passed correctly, as it's 0 without optimizations and 512 with, which is what w_param should be (WM_MOUSEHOOK value).

edit2:

Seems to be a compiler bug. Based on the asm output, either rustc 1.78 or llvm 18 are miscompiling the hook function.

timrobertsdev commented 3 months ago

Fixed in the latest commit! Seems like I introduced some UB that wasn't actually an issue until 1.78.