seL4 / microkit

Microkit - A simple operating system framework for the seL4 microkernel
Other
70 stars 37 forks source link

BorrowMutError panic in sel4cp main #37

Closed sid-agrawal closed 10 months ago

sid-agrawal commented 10 months ago

The compilation worked fine after two hick-ups (I wasn't sure where to install the arm toolchain and had to upgrade pyoxidizer, both are sorted).

RUST_BACKTRACE=full ./release/sel4cp-sdk-1.2.6/bin/sel4cp
thread 'main' panicked at 'already borrowed: BorrowMutError', /home/siagraw/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.17.3/src/gil.rs:433:45
stack backtrace:
   0:     0x7f52aead67b0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::had334ddb529a2169
   1:     0x7f52aeb62c5e - core::fmt::write::h1aa7694f03e44db2
   2:     0x7f52aeac80f5 - <unknown>
   3:     0x7f52aead6575 - <unknown>
   4:     0x7f52aead937f - <unknown>
   5:     0x7f52aead90ba - std::panicking::default_hook::he03a933a0f01790f
   6:     0x7f52aead9b28 - std::panicking::rust_panic_with_hook::he26b680bfd953008
   7:     0x7f52aead98c7 - <unknown>
   8:     0x7f52aead6c5c - <unknown>
   9:     0x7f52aead95e2 - rust_begin_unwind
  10:     0x7f52adc920d3 - core::panicking::panic_fmt::he7679b415d25c5f4
  11:     0x7f52adc92393 - core::result::unwrap_failed::hb71caff146724b6b
  12:     0x7f52adf42086 - pyo3::gil::register_owned::h998547cdd21fc09e
  13:     0x7f52adf548c8 - pyo3::types::string::PyString::new::heccde79697d72abe
  14:     0x7f52adc94e4d - <unknown>
  15:     0x7f52adc96aa4 - pyembed::interpreter::MainPythonInterpreter::new::h6ff8b944283a0e80
  16:     0x7f52adc93345 - <unknown>
  17:     0x7f52adc93663 - <unknown>
  18:     0x7f52adc927d9 - <unknown>
  19:     0x7f52aeab91ee - std::rt::lang_start_internal::h167a33dedfef305a
  20:     0x7f52adc93655 - main
Ivan-Velickovic commented 10 months ago

I don't think I've run into this error before. Do you mind reporting what Linux distro you are using (and version) and what pyoxidzier version you upgraded in order to fix the issue?

sid-agrawal commented 10 months ago

Ubuntu 22.04

 ./pyenv/bin/python3 -m pip show pyoxidizer
Name: pyoxidizer
Version: 0.24.0
Summary: Package self-contained Python applications
Home-page: https://github.com/indygreg/PyOxidizer
Author: Gregory Szorc <gregory.szorc@gmail.com>
Author-email: Gregory Szorc <gregory.szorc@gmail.com>
License: MPL-2.0
Location: /home/siagraw/OSmosis/sel4cp/pyenv/lib/python3.9/site-packages
Requires:
Required-by:
Ivan-Velickovic commented 10 months ago

Okay it looks like https://github.com/indygreg/PyOxidizer/issues/673 is the appropriate bug report in PyOxidizer. Will have to take a closer look, but it looks like we might have to upgrade PyOxidizer versions.

Ivan-Velickovic commented 10 months ago

So just to confirm, it didn't work with the current version of PyOxidizer (0.17.0), but did work with version 0.24.0?

sid-agrawal commented 10 months ago

No, sorry about the confusion.

It did not work with 0.17.0 for a different issue #13. This was a compile failure.

To fix #13 , I upgraded to 0.24.0, which is what happens when I do ./pyenv/bin/python3 -m pip install --upgrade pyoxidizer. The compile fails, but I get an error reported in this issue at runtime.

Now I downgraded the pyoxidizer package to 0.23.0, and trying again.

Ivan-Velickovic commented 10 months ago

Please see this comment: https://github.com/BreakawayConsulting/sel4cp/issues/13#issuecomment-1510565071. The issue comes from installing musl-tools from apt on Ubuntu 22.04. If you build from source you won't have that issue. Do you mind building musl 1.2.2 as specified in the README without upgrading PyOxidizer and reporting the results?

sid-agrawal commented 10 months ago

Sure. I can try that next. btw, switching the pyoxidizer package to 0.23.0 also fixes it.

Ivan-Velickovic commented 10 months ago

The following commands should work:

wget https://musl.libc.org/releases/musl-1.2.2.tar.gz
tar xvf musl-1.2.2.tar.gz
cd musl-1.2.2
./configure
make -j$(nproc)
sudo make install

Note you'll probably have to do sudo apt remove musl-tools first.

Ivan-Velickovic commented 10 months ago

The default make install location for musl is /usr/local/musl/bin/ so make sure to have that in your PATH as well.

sid-agrawal commented 10 months ago

I can confirm that the sel4cp tool compiles and run with:

Ivan-Velickovic commented 10 months ago

Great, the only thing to do now is document this process so that anyone else on Ubuntu 22.04 (or some other distro) does not run into this.