hobofan / cargo-nono

Check your crate for (possible) no_std compatibility
Apache License 2.0
209 stars 12 forks source link

StripPrefixError panic #22

Closed hobofan closed 4 years ago

hobofan commented 5 years ago

Running

RUST_BACKTRACE=full cargo nono check --package cranelift-wasm

on https://github.com/CraneStation/cranelift/tree/4e096e29cecc762e345cfc62c34e3113ba5777d7 in dir lib/wasm panics with:

cranelift-entity: ❌
  - Source code contains an explicit `use std::` statement.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: StripPrefixError(())', src/libcore/result.rs:1009:5
stack backtrace:
   0:        0x109393923 - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h16b82ef029078385
   1:        0x10938e65c - std::sys_common::backtrace::_print::hc39c8623f5320a3a
   2:        0x1093929f1 - std::panicking::default_hook::{{closure}}::h928a543b2f8eb1f2
   3:        0x1093926ed - std::panicking::default_hook::hb3ba6facbede384c
   4:        0x10939311e - std::panicking::rust_panic_with_hook::h3fe6a67edb032589
   5:        0x109392c3c - std::panicking::continue_panic_fmt::hf7169aba6b1afe9c
   6:        0x109392b28 - rust_begin_unwind
   7:        0x1093aa811 - core::panicking::panic_fmt::hf684b13de6e3dd2d
   8:        0x10919881b - core::result::unwrap_failed::hf0b422043be0127e
   9:        0x109200dd9 - <&T as core::fmt::Display>::fmt::h6f4aab4dbc41c75d
  10:        0x1093addb1 - core::fmt::write::h07cb3932825b7927
  11:        0x109389437 - <std::io::stdio::Stdout as std::io::Write>::write_fmt::hdf30f8e7bf3cc5dc
  12:        0x10938a027 - std::io::stdio::_print::h17becc1f62571f8c
  13:        0x10920efae - cargo_nono::check_and_print_package::h49baee39823b48e2
  14:        0x109210e3e - cargo_nono::main::h7c5c26de94d8f9f2
  15:        0x1091f11e5 - std::rt::lang_start::{{closure}}::hdf35957c19b19ff4
  16:        0x109392aa7 - std::panicking::try::do_call::hb3270f6ae846849d
  17:        0x1093a48fe - __rust_maybe_catch_panic
  18:        0x10939343a - std::rt::lang_start_internal::ha07e743882e341f3
  19:        0x109211568 - main
caemor commented 5 years ago

When running it on curve25519-dalek it also panicks there:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: StripPrefixError(())', src/libcore/result.rs:997:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:385
   6: rust_begin_unwind
             at src/libstd/panicking.rs:312
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   8: core::result::unwrap_failed
   9: <&T as core::fmt::Display>::fmt
  10: core::fmt::write
             at src/libcore/fmt/mod.rs:1016
  11: <std::io::stdio::Stdout as std::io::Write>::write_fmt
             at src/libstd/io/mod.rs:1250
             at src/libstd/io/stdio.rs:484
  12: std::io::stdio::_print
             at src/libstd/io/stdio.rs:729
             at src/libstd/thread/local.rs:300
             at src/libstd/io/stdio.rs:723
             at src/libstd/io/stdio.rs:744
  13: cargo_nono::check_and_print_package
  14: cargo_nono::main
  15: std::rt::lang_start::{{closure}}
  16: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:297
  17: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  18: std::rt::lang_start_internal
             at src/libstd/panicking.rs:276
             at src/libstd/panic.rs:388
             at src/libstd/rt.rs:48
  19: main
  20: __libc_start_main
  21: _start
caemor commented 5 years ago

https://github.com/hobofan/cargo-nono/blob/f1caba3aefabe98fe7536fc3f32487dbeeac4339/src/check_source.rs#L133-L134 The unwrap in the 2nd line causes the panic that i found above.

hobofan commented 4 years ago

Fixed and released in 0.1.8