Fix unsound Send+Sync impl#14797
Conversation
Package Changes Through 1e8fca7There are 9 changes which include tauri-utils with patch, tauri-build with patch, tauri-cli with minor, tauri-macos-sign with patch, @tauri-apps/cli with minor, tauri with minor, tauri-bundler with minor, tauri-runtime-wry with minor, tauri-runtime with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
|
@WSH032 if you're still around, will this cause issues for you? |
|
While on the topic of unsoundness, I previously filed #13257 and wry PR1571 to tighten up the code and be a bit more defensive about unsafe in general, but it seems they never got the necessary traction. Would appreciate some feedback regarding how to proceed with them. |
|
Woops, I should have run the code instead of just compiling it, my bad. The setup error is caught here and stringified. So luckily there isn't a way to get an unsound crash from it. I'll open a separate issue for the remaining issue. if let Err(e) = setup(&mut self) {
panic!("Failed to setup app: {e}");
} |
This is a tiny breaking change to fix an unsoundness in the public API of tauri.
There is no non-breaking change that could fix this, and anybody without a Sync+Send error type is doing something shady anyway.
The issue is we can have an error type with an
Rcthat is then laundered by the Tauriunsafe implinto aSetupErrorwhich can be freely sent to a different thread. See this modification of helloworld.rsThere is another soundness issue in
tauri-runtime-wry'sWindowsStorewhere there's an unsafeSyncimpl even though the inner type is public. I haven't been able to verify whether the code was ever sound, but since the inner field was made public it definitely became unsound,RefCellis notSync, but the wrapper type is, so we can trivially send references toWindowsStoreto multiple threads and then open them up to references toRefCell.The safety comments "// SAFETY: we ensure this type is only used on the main thread." are incorrect.