starcoinorg / starcoin

Starcoin - A Move smart contract blockchain network that scales by layering
Apache License 2.0
1.38k stars 289 forks source link

[vm] compile smart contract pops a panic #2258

Closed AlexiaChen closed 3 years ago

AlexiaChen commented 3 years ago

use cli to compile a contract:

startcoin% dev compile <wrong path of *.move file>

my cli command as follows(the file actually exists):

dev compile /home/mathxh/Project/starcoin/examples/finger_guess/module/finger_guess.move

and panic pops up,

Here is my question: Does the command support absolute paths? I just read related code, it does definitely support absolute path. and it panic in internal of vm module:

pub fn stdlib_files() -> Vec<String> {
    let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
    path.push(STD_LIB_DIR);
    let dirfiles = datatest_stable::utils::iterate_directory(&path);
    filter_move_files(dirfiles).collect::<Vec<_>>()
}

It just iter STD_LIB_DIR and panic!

BackTrace:

2021-03-09T17:17:39.865363400+08:00 ERROR - panic occurred:
2021-03-09T17:17:39.865477700+08:00 ERROR - details: panicked at 'called `Result::unwrap()` on an `Err` value: Error { depth: 0, inner: Io { path: Some("/home/runner/work/starcoin/starcoin/vm/stdlib/modules"), err: Os { code: 2, kind: NotFound, message: "No such file or directory" } } }', /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/ops/function.rs:150:5
2021-03-09T17:17:39.865496800+08:00 ERROR - backtrace:    0:     0x55fa7cccac15 - backtrace::capture::Backtrace::create::hdd2377ea43fecba1
   1:     0x55fa7cccab43 - backtrace::capture::Backtrace::new::h4aa08d3c41aa7e16
   2:     0x55fa7b2862c0 - starcoin_node::crash_handler::handle_panic::h3163385e00435dfb
                               at /home/runner/work/starcoin/starcoin/node/src/crash_handler.rs:21:38
   3:     0x55fa7b286239 - starcoin_node::crash_handler::setup_panic_handler::{{closure}}::h6adadd5f309af2a4
                               at /home/runner/work/starcoin/starcoin/node/src/crash_handler.rs:14:9
   4:     0x55fa7cd924e6 - std::panicking::rust_panic_with_hook::hb27ea14285131c61
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:595:17
   5:     0x55fa7cd92007 - std::panicking::begin_panic_handler::{{closure}}::hc552fcee62aad17f
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:497:13
   6:     0x55fa7cd8f9fc - std::sys_common::backtrace::__rust_end_short_backtrace::hb9f0aa9a78e885a0
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/sys_common/backtrace.rs:141:18
   7:     0x55fa7cd91f69 - rust_begin_unwind
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:493:5
   8:     0x55fa7cdb07e1 - core::panicking::panic_fmt::h12ac4570ea43d06f
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:92:14
   9:     0x55fa7cdb04a3 - core::option::expect_none_failed::h096fa60f757b7204
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/option.rs:1268:5
  10:     0x55fa7c36e332 - <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold::h0ade966f08334402
  11:     0x55fa7c3495e8 - <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next::h9c8b3e7aef7bfdba
  12:     0x55fa7c355dc6 - <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter::h632d85e04f4db2cd
  13:     0x55fa7c35d01a - stdlib::stdlib_files::hc6d8adabc8f7d9a2
  14:     0x55fa7b1c15c3 - <starcoin_cmd::dev::compile_cmd::CompileCommand as scmd::action::CommandAction>::run::hbd1e213dbacf7a1c
  15:     0x55fa7b1fead6 - scmd::command::Command<State,GlobalOpt,Opt,ReturnItem,Action>::exec_action::h4eddf01233f64684
  16:     0x55fa7b1c8035 - <scmd::command::Command<State,GlobalOpt,Opt,ReturnItem,Action> as scmd::command::CommandExec<State,GlobalOpt>>::exec::h01340a876b99751d
  17:     0x55fa7b1d51de - <scmd::command::Command<State,GlobalOpt,Opt,ReturnItem,Action> as scmd::command::CommandExec<State,GlobalOpt>>::exec::h89b88a38f62007d7
  18:     0x55fa7b1162a3 - scmd::context::CmdContext<State,GlobalOpt>::exec_inner::h46f3dc9c87db5896
  19:     0x55fa7b1185e4 - scmd::context::CmdContext<State,GlobalOpt>::exec::h02fc278380433be3
  20:     0x55fa7b130997 - starcoin::main::h9a88867b93a77be5
  21:     0x55fa7b10a0e3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h9d3dd906e2ca6413
  22:     0x55fa7b10a0f9 - std::rt::lang_start::{{closure}}::h6848cb7bbcfc4e5a
  23:     0x55fa7cd929d7 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h78040f802d89ccdc
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/ops/function.rs:259:13
                           std::panicking::try::do_call::h6853cad536dd09a1
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:379:40
                           std::panicking::try::h827495f03a9fbb9a
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:343:19
                           std::panic::catch_unwind::h4bdf17571090eb17
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panic.rs:396:14
                           std::rt::lang_start_internal::h2f319c33bb013f29
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/rt.rs:51:25
  24:     0x55fa7b131072 - main
jolestar commented 3 years ago

Please clone the starcoin repo and run cargo build at local, then use the dev compile command. Because the compile command needs the stdlib source files.