Skip to content
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

[bug][installer] Installer launched from updater plugin may fails with Failed to kill <APPNAME>. Please close it first then try again #12309

Open
anatawa12 opened this issue Jan 8, 2025 · 0 comments
Labels
platform: Windows status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@anatawa12
Copy link
Contributor

Describe the bug

Installer launched from updater plugin may fails with Failed to kill <APPNAME>. Please close it first then try again, but it's actually exited already (by updater plugin)

This happens relatively rarely but have received reports from several users, and I may experience the problem/
It's hard to reproduce now, but when happens, retrying with updater would likely to cause same problem so some OS internal state is related I feel.

Reproduction

Starting NSIS installer from updater plugin would cause problem, but not always.

Expected behavior

No such error should happens

Full tauri info output

[✔] Environment
    - OS: Mac OS 15.0.1 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.83.0 (90b35a623 2024-11-26)
    ✔ cargo: 1.83.0 (5ffbef321 2024-10-29)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 22.6.0
    - pnpm: 8.15.4
    - npm: 10.8.2
    - deno: deno 1.45.5

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.2
    - tao 🦀: 0.30.8
    - tauri-cli 🦀: 2.0.0-rc.3
    - @tauri-apps/api : 2.1.1 (outdated, latest: 2.2.0)
    - @tauri-apps/cli : 2.1.0 (outdated, latest: 2.2.2)

[-] Plugins
    - tauri-plugin-dialog 🦀: 2.2.0
    - @tauri-apps/plugin-dialog : not installed!
    - tauri-plugin-single-instance 🦀: 2.2.0
    - @tauri-apps/plugin-single-instance : not installed!
    - tauri-plugin-updater 🦀: 2.3.0
    - @tauri-apps/plugin-updater : not installed!
    - tauri-plugin-fs 🦀: 2.2.0
    - @tauri-apps/plugin-fs : not installed!

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: out
    - devUrl: http://localhost:3030/
    - framework: React (Next.js)
    - bundler: Webpack

Stack trace

No response

Additional context

I feel something like TOCTOU problem in nsis-tauri-updater.

It looks get_processes (and underlying win32 api?) may returns pid for recently exited process, and kill doesn't check if OpenProcess fails with 0x80070057 (E_INVALIDARG).
As far as I tried with win 11, OpenProcess will fails with E_INVALIDARG if the process already exits.

https://github.com/tauri-apps/nsis-tauri-utils/blob/14d311b13f598508cfa48fae66db3cfb5a30d3bf/crates/nsis-process/src/lib.rs#L207-L231
https://github.com/tauri-apps/nsis-tauri-utils/blob/14d311b13f598508cfa48fae66db3cfb5a30d3bf/crates/nsis-process/src/lib.rs#L159-L164

For reference:

  • if the process exited before OpenProcess, OpenProcess will fails with 0x80070057 (E_INVALIDARG)
  • if the process exited between OpenProcess and TerminateProcess, TerminateProcess will fails with 0x80070005 (E_ACCESSDENIED)
  • if the installer lacks privilege for killing the process, OpenProcess will fails with 0x80070005 (E_ACCESSDENIED). (I tested with killing cmd.exe running as SYSTEM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Windows status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants