tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.53k stars 2.58k forks source link

"--verbose" parameter cause "cargo tauri build" error #8110

Closed yang4515 closed 11 months ago

yang4515 commented 1 year ago

Describe the bug

When I add "--verbose" parameter, I got:

thread '<unnamed>' panicked at /Users/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tauri-bundler-1.4.5/src/bundle/common.rs:191:46:
byte index 18446744073709551615 is out of bounds of ``
stack backtrace:
Creating disk image...
   0:        0x108beecd1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h65343ad3a85b4e34
   1:        0x1086ec4ab - core::fmt::write::h11839d3825cb5605
   2:        0x108bbc1ae - std::io::Write::write_fmt::h3ab12d369399333c
   3:        0x108bf4479 - std::sys_common::backtrace::print::h405f7c76ca12eb27
   4:        0x108bf40a5 - std::panicking::default_hook::{{closure}}::hed87c355606e1822
   5:        0x108bf3d6f - std::panicking::default_hook::hdf696ec8ea0d65aa
   6:        0x108bf4d65 - std::panicking::rust_panic_with_hook::h7c5059af1af54377
   7:        0x108bf4b44 - std::panicking::begin_panic_handler::{{closure}}::hd658b0e1cffe3d4d
   8:        0x108bf4aa9 - std::sys_common::backtrace::__rust_end_short_backtrace::h3d7834d0cea60a50
   9:        0x108bf4a92 - _rust_begin_unwind
  10:        0x109184073 - core::panicking::panic_fmt::ha9964785de0afb40
  11:        0x1086f4de8 - core::str::slice_error_fail_rt::hdab0588c7b50926d
  12:        0x109184609 - core::str::slice_error_fail::h85725224eed85dfc
  13:        0x108c00135 - std::sys_common::backtrace::__rust_begin_short_backtrace::h02c11099bc04e68c
  14:        0x108c3ed61 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h2e29327d71dd9385
  15:        0x108bf8b39 - std::sys::unix::thread::Thread::new::thread_start::h153c4d3159ba46be
  16:     0x7ff818cc54e1 - __pthread_start
thread 'main' panicked at /Users/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tauri-bundler-1.4.5/src/bundle/common.rs:200:56:
called `Result::unwrap()` on an `Err` value: PoisonError { .. }
stack backtrace:
   0:        0x108beecd1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h65343ad3a85b4e34
   1:        0x1086ec4ab - core::fmt::write::h11839d3825cb5605
   2:        0x108bbc1ae - std::io::Write::write_fmt::h3ab12d369399333c
   3:        0x108bf4479 - std::sys_common::backtrace::print::h405f7c76ca12eb27
   4:        0x108bf40a5 - std::panicking::default_hook::{{closure}}::hed87c355606e1822
   5:        0x108bf3d6f - std::panicking::default_hook::hdf696ec8ea0d65aa
   6:        0x108bf4d65 - std::panicking::rust_panic_with_hook::h7c5059af1af54377
   7:        0x108bf4b44 - std::panicking::begin_panic_handler::{{closure}}::hd658b0e1cffe3d4d
   8:        0x108bf4aa9 - std::sys_common::backtrace::__rust_end_short_backtrace::h3d7834d0cea60a50
   9:        0x108bf4a92 - _rust_begin_unwind
  10:        0x109184073 - core::panicking::panic_fmt::ha9964785de0afb40
  11:        0x1091844a1 - core::result::unwrap_failed::h789415aec617156b
  12:        0x108c0776d - <std::process::Command as tauri_bundler::bundle::common::CommandExt>::output_ok::h93d92cf848259b92
  13:        0x108c0aeb4 - tauri_bundler::bundle::bundle_project::h66f302d8f0bb289d
  14:        0x108e4dd72 - tauri_cli::build::command::h9e3f86d7df04e8dd
  15:        0x108635717 - tauri_cli::run::h96836811ba49b9ec
  16:        0x10868be97 - cargo_tauri::main::h92882854e2996cf2
  17:        0x10868b076 - std::sys_common::backtrace::__rust_begin_short_backtrace::h98179b40a915f3c7
  18:        0x10868b963 - _main

And everything returns to normal when I remove the --verbose parameter. I was unable to reproduce the issue using the official demo. The log provides the file and the line number where the error occurred. I am not familiar with Rust, can you provide some help?

Reproduction

No response

Expected behavior

No response

Platform and versions

[✔] Environment
    - OS: Mac OS 12.6.8 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.73.0 (cc66ad468 2023-10-03)
    ✔ Cargo: 1.73.0 (9c4383fb5 2023-08-26)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-apple-darwin (environment override by RUSTUP_TOOLCHAIN)
    - node: 18.16.0
    - pnpm: 8.4.0
    - yarn: 1.22.19
    - npm: 7.6.0

[-] Packages
    - tauri [RUST]: 1.5.2
    - tauri-build [RUST]: 1.5.0
    - wry [RUST]: 0.24.4
    - tao [RUST]: 0.16.2
    - tauri-cli [RUST]: 1.5.0
    - @tauri-apps/api [NPM]: 1.5.1
    - @tauri-apps/cli [NPM]: 1.5.0 (outdated, latest: 1.5.6)

[-] App
    - build-type: bundle
    - CSP: unset

Stack trace

No response

Additional context

No response

olivierlemasle commented 1 year ago

This is a regression from #8042.

The panic occurs line 191 when line is empty and debug logging is enabled:

https://github.com/tauri-apps/tauri/blob/ae75004cee126c4bac332643c49869d2cfe38ad1/tooling/bundler/src/bundle/common.rs#L183-L194

olivierlemasle commented 1 year ago

The error occurs when read_line returns an error (e.g. invalid UTF-8 character).

@yang4515 As you were unable to reproduce the issue with a demo, could you please provide us with the (verbose) logs before the failure? At least a few lines, including one with the words Running and Command...

yang4515 commented 1 year ago

@olivierlemasle The last command executed was bundle_dmg.sh, the difference between the demo and my application is that the demo is not signed, this issue may be related to the signature.

     Running [tauri_bundler::bundle::common] Command `security  list-keychain -d user -s /Users/dev/Library/Keychains/login.keychain-db /private/var/folders/dv/xxx/T/t-YDPWjo/1.keychain tauri-build.keychain`
        Info [tauri_bundler::bundle::macos::sign] Signing app bundle...
     Signing [tauri_bundler::bundle::macos::sign] /var/folders/dv/xxx/T/.tmpkZZROQ/AppName.zip
     Running [tauri_bundler::bundle::common] Command `security  delete-keychain tauri-build.keychain`
  Notarizing [tauri_bundler::bundle::macos::sign] ~/appDir/target/release/bundle/macos/AppName.app
     Running [tauri_bundler::bundle::common] Command `xcrun  stapler staple -v AppName.app`
Processing: ~/appDir/target/release/bundle/macos/AppName.app
Domain is api.apple-cloudkit.com
Response is <NSHTTPURLResponse: 0x600002ddf380> { URL: https://api.apple-cloudkit.com/database/1/com.apple.gk.ticket-delivery/production/public/records/lookup } { Status Code: 200, Headers {
  ...
} }
Size of data is 2877
JSON Response is: {
  ...
}
Downloaded ticket has been stored at file:///var/folders/dv/xxx/T/xxx.ticket.
Processing: ~/appDir/target/release/bundle/macos/AppName.app
Properties are {
    NSURLIsDirectoryKey = 1;
    NSURLIsPackageKey = 1;
    NSURLIsSymbolicLinkKey = 0;
    NSURLLocalizedTypeDescriptionKey = Application;
    NSURLTypeIdentifierKey = "com.apple.application-bundle";
    "_NSURLIsApplicationKey" = 1;
}
Props are {
  ...
}
The staple and validate action worked!
    Bundling [tauri_bundler::bundle::macos::dmg] AppName.app
     Running [tauri_bundler::bundle::macos::dmg] bundle_dmg.sh
     Running [tauri_bundler::bundle::common] Command `~/appDir/target/release/bundle/dmg/bundle_dmg.sh xxx`
+ WINX=10
+ WINY=60
+ WINW=500
+ WINH=350
+ ICON_SIZE=128
+ TEXT_SIZE=16
+ FORMAT=UDZO
+ ADD_FILE_SOURCES=()
+ ADD_FILE_TARGETS=()
+ IMAGEKEY=
+ HDIUTIL_VERBOSITY=
+ SANDBOX_SAFE=0
+ BLESS=0
+ SKIP_JENKINS=0
+ MAXIMUM_UNMOUNTING_ATTEMPTS=3
+ POSITION_CLAUSE=
+ HIDING_CLAUSE=
+ [[ - = \- ]]
+ case $1 in
thread '<unnamed>' panicked at /Users/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tauri-bundler-1.4.5/src/bundle/common.rs:191:46:
byte index 18446744073709551615 is out of bounds of ``
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at /Users/dev/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/tauri-bundler-1.4.5/src/bundle/common.rs:200:56:
called `Result::unwrap()` on an `Err` value: PoisonError { .. }
child_process.js:866
    throw err;
olivierlemasle commented 1 year ago

Thanks @yang4515, this is not related to signature but to product name.

I noticed that the error occured when normally the product name is printed, so I managed to reproduce the issue with productName emoji-🍎:

    Bundling [tauri_bundler::bundle::macos::dmg] emoji-🍎_0.0.0_x64.dmg (/Users/runner/work/demo-stable/demo-stable/src-tauri/target/release/bundle/dmg/emoji-🍎_0.0.0_x64.dmg)
     Running [tauri_bundler::bundle::macos::dmg] bundle_dmg.sh
     Running [tauri_bundler::bundle::common] Command `/Users/runner/work/demo-stable/demo-stable/src-tauri/target/release/bundle/dmg/bundle_dmg.sh  --volname emoji-🍎 --icon emoji-🍎.app 180 170 --app-drop-link 480 170 --window-size 660 400 --hide-extension emoji-🍎.app --volicon /Users/runner/work/demo-stable/demo-stable/src-tauri/target/release/bundle/dmg/icon.icns --skip-jenkins emoji-🍎_0.0.0_x64.dmg emoji-🍎.app`
+ WINX=10
+ WINY=60
+ WINW=500
+ WINH=350
+ ICON_SIZE=128
+ TEXT_SIZE=16
+ FORMAT=UDZO
+ ADD_FILE_SOURCES=()
+ ADD_FILE_TARGETS=()
+ IMAGEKEY=
+ HDIUTIL_VERBOSITY=
+ SANDBOX_SAFE=0
+ BLESS=0
+ SKIP_JENKINS=0
+ MAXIMUM_UNMOUNTING_ATTEMPTS=3
+ POSITION_CLAUSE=
+ HIDING_CLAUSE=
+ [[ - = \- ]]
+ case $1 in
thread '<unnamed>' panicked at /Users/runner/work/tauri/tauri/tooling/bundler/src/bundle/common.rs:191:46:
byte index 18446744073709551615 is out of bounds of ``
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at /Users/runner/work/tauri/tauri/tooling/bundler/src/bundle/common.rs:200:56:
called `Result::unwrap()` on an `Err` value: PoisonError { .. }

Of course you removed the product name from the logs, but I guess it included a Chinese character or another 2-bytes character such as an emoji. Am I right?

I'll now be able to submit a PR to fix this issue.

yang4515 commented 1 year ago

@olivierlemasle Yes, the product name includes Chinese characters.