facebookexperimental / hermit

Hermit launches linux x86_64 programs in a special, hermetically isolated sandbox to control their execution. Hermit translates normal, nondeterministic behavior, into deterministic, repeatable behavior. This can be used for various applications, including replay-debugging, reproducible artifacts, chaos mode concurrency testing and bug analysis.
Other
1.17k stars 31 forks source link

Panic on hello world java program #19

Open meisterT opened 1 year ago

meisterT commented 1 year ago

Describe the bug A simple Java program executed under hermit causes a panic.

Indicate any of these common scenarios that apply:

To Reproduce Minimal input to reproduce the behavior.

$ cat HelloWorld.java 
public class HelloWorld {
    public static void main(String[] args) throws Exception {
        System.out.println("Hello world!");
    }
}
$ javac HelloWorld.java && RUST_BACKTRACE=1 hermit/target/debug/hermit run --summary -- java HelloWorld
WARNING: --preemption-timout requires hardware perf counters which is not supported on this host, resetting preemption-timeout to 0
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/sitowert/hermit/detcore/src/lib.rs:592:36
stack backtrace:
   0: rust_begin_unwind
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/panicking.rs:65:14
   2: core::panicking::panic
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/panicking.rs:114:5
   3: core::option::Option<T>::unwrap
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/option.rs:778:21
   4: detcore::<impl reverie::tool::Tool for detcore::tool_local::Detcore<T>>::handle_cpuid_event::{{closure}}
             at ./hermit/detcore/src/lib.rs:592:13
   5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
   6: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll{{reify.shim}}
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:86:9
   7: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/future.rs:124:9
   8: reverie_ptrace::task::TracedTask<L>::handle_cpuid::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-ptrace/src/task.rs:802:13
   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  10: reverie_ptrace::task::TracedTask<L>::handle_sigsegv::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-ptrace/src/task.rs:952:51
  11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  12: reverie_ptrace::task::TracedTask<L>::handle_signal::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-ptrace/src/task.rs:974:57
  13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  14: reverie_ptrace::task::TracedTask<L>::handle_stop_event::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-ptrace/src/task.rs:867:67
  15: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  16: <futures_util::future::future::fuse::Fuse<Fut> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/fuse.rs:86:37
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/future.rs:124:9
  18: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/future.rs:124:9
  19: futures_util::future::future::FutureExt::poll_unpin
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/mod.rs:562:9
  20: reverie_ptrace::task::TracedTask<L>::run_loop_internal::{{closure}}::{{closure}}::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/async_await/select_mod.rs:331:13
  21: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ops/function.rs:617:13
  22: reverie_ptrace::task::TracedTask<L>::run_loop_internal::{{closure}}::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/async_await/select_mod.rs:331:13
  23: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/poll_fn.rs:56:9
  24: reverie_ptrace::task::TracedTask<L>::run_loop_internal::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-ptrace/src/task.rs:1430:34
  25: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  26: reverie_ptrace::task::TracedTask<L>::run_loop::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-ptrace/src/task.rs:1374:43
  27: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  28: <futures_util::future::future::fuse::Fuse<Fut> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/fuse.rs:86:37
  29: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/future.rs:124:9
  30: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/future.rs:124:9
  31: futures_util::future::future::FutureExt::poll_unpin
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/mod.rs:562:9
  32: reverie_ptrace::task::TracedTask<L>::run::{{closure}}::{{closure}}::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/async_await/select_mod.rs:331:13
  33: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/ops/function.rs:617:13
  34: reverie_ptrace::task::TracedTask<L>::run::{{closure}}::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/async_await/select_mod.rs:331:13
  35: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/poll_fn.rs:56:9
  36: reverie_ptrace::task::TracedTask<L>::run::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-ptrace/src/task.rs:1458:13
  37: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  38: reverie_ptrace::task::TracedTask<L>::handle_new_task::{{closure}}::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-ptrace/src/task.rs:1162:40
  39: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  40: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/task/core.rs:208:17
  41: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/loom/std/unsafe_cell.rs:14:9
  42: tokio::runtime::task::core::Core<T,S>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/task/core.rs:197:13
  43: tokio::runtime::task::harness::poll_future::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/task/harness.rs:483:19
  44: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/panic/unwind_safe.rs:271:9
  45: std::panicking::try::do_call
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/std/src/panicking.rs:483:40
  46: __rust_try
  47: std::panicking::try
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/std/src/panicking.rs:447:19
  48: std::panic::catch_unwind
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/std/src/panic.rs:137:14
  49: tokio::runtime::task::harness::poll_future
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/task/harness.rs:471:18
  50: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/task/harness.rs:107:27
  51: tokio::runtime::task::harness::Harness<T,S>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/task/harness.rs:61:15
  52: tokio::runtime::task::raw::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/task/raw.rs:194:5
  53: tokio::runtime::task::raw::RawTask::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/task/raw.rs:134:18
  54: tokio::runtime::task::LocalNotified<S>::run
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/task/mod.rs:430:9
  55: tokio::task::local::LocalSet::tick::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/task/local.rs:616:63
  56: tokio::runtime::coop::with_budget
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/coop.rs:102:5
  57: tokio::runtime::coop::budget
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/coop.rs:68:5
  58: tokio::task::local::LocalSet::tick
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/task/local.rs:616:31
  59: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/task/local.rs:928:16
  60: tokio::task::local::LocalSet::with::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/task/local.rs:685:13
  61: std::thread::local::LocalKey<T>::try_with
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/std/src/thread/local.rs:446:16
  62: std::thread::local::LocalKey<T>::with
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/std/src/thread/local.rs:422:9
  63: tokio::task::local::LocalSet::with
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/task/local.rs:668:9
  64: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/task/local.rs:914:9
  65: tokio::task::local::LocalSet::run_until::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/task/local.rs:574:18
  66: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  67: reverie_ptrace::tracer::Tracer<G>::wait::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-ptrace/src/tracer.rs:136:59
  68: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  69: hermit::run::{{closure}}
             at ./hermit/hermit-cli/src/lib.rs:83:68
  70: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/mod.rs:92:19
  71: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/future/future.rs:124:9
  72: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/scheduler/current_thread.rs:531:57
  73: tokio::runtime::coop::with_budget
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/coop.rs:102:5
  74: tokio::runtime::coop::budget
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/coop.rs:68:5
  75: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/scheduler/current_thread.rs:531:25
  76: tokio::runtime::scheduler::current_thread::Context::enter
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/scheduler/current_thread.rs:340:19
  77: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/scheduler/current_thread.rs:530:36
  78: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/scheduler/current_thread.rs:601:57
  79: tokio::macros::scoped_tls::ScopedKey<T>::set
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/macros/scoped_tls.rs:61:9
  80: tokio::runtime::scheduler::current_thread::CoreGuard::enter
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/scheduler/current_thread.rs:601:27
  81: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/scheduler/current_thread.rs:520:19
  82: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/scheduler/current_thread.rs:154:24
  83: tokio::runtime::runtime::Runtime::block_on
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.22.0/src/runtime/runtime.rs:279:47
  84: hermit::run
             at ./hermit/hermit-cli/src/lib.rs:85:5
  85: hermit::run::RunOpts::run_in_container
             at ./hermit/hermit-cli/src/bin/hermit/run.rs:933:9
  86: hermit::run::RunOpts::run::{{closure}}
             at ./hermit/hermit-cli/src/bin/hermit/run.rs:737:43
  87: hermit::container::with_container::{{closure}}
             at ./hermit/hermit-cli/src/bin/hermit/container.rs:44:17
  88: reverie_process::container::Container::run::{{closure}}::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-process/src/container.rs:794:68
  89: core::result::Result<T,E>::map
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/core/src/result.rs:775:25
  90: reverie_process::container::Container::run::{{closure}}
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-process/src/container.rs:794:29
  91: <alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut
             at /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/library/alloc/src/boxed.rs:2016:9
  92: reverie_process::clone::clone_with_stack::callback
             at ./.cargo/git/checkouts/reverie-9a587e40a0d7d3be/6f03658/reverie-process/src/clone.rs:29:9
  93: __GI___clone
             at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:100
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Expected behavior Hermit can handle the execution of Java programs on the JVM.

Environment

Additional context Attach the logs to this issue as a text file generated by hermit --log=trace --log-file=FOO run.

log.txt

Add any other context about the problem here.

smarter commented 1 year ago

As a workaround, using hermit run --no-virtualize-cpuid java ... is enough to get java programs to work for me (using java 17 at least, java 8 seems to hang forever)