In build.rs the function fn into_pcwstr(self) -> PCWSTR returns PCWSTR which is basically a pointer to an internal variable that expires immediately after function returns, and even though it's used immediately it's apparently enough for the data it points to get corrupted.
I believe windows-rs library it relies on has already addressed this issue and provided some workaround in release 0.44.0.
Right now winpty-rs is using windows 0.43.0
This is the description of the change microsoft/windows-rs#2239 and apparently you can use HSTRING instead of PCWSTR in most cases now, which is safer.
This seems to work:
In
build.rs
the functionfn into_pcwstr(self) -> PCWSTR
returns PCWSTR which is basically a pointer to an internal variable that expires immediately after function returns, and even though it's used immediately it's apparently enough for the data it points to get corrupted.I believe
windows-rs
library it relies on has already addressed this issue and provided some workaround in release0.44.0
. Right nowwinpty-rs
is usingwindows 0.43.0
This is the description of the change microsoft/windows-rs#2239 and apparently you can use HSTRING instead of PCWSTR in most cases now, which is safer. This seems to work: