Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GuixSD panics with Option::unwrap() #848

Closed
leroycep opened this issue Jan 20, 2017 · 6 comments
Closed

GuixSD panics with Option::unwrap() #848

leroycep opened this issue Jan 20, 2017 · 6 comments

Comments

@leroycep
Copy link

I am writing an application using conrod and using piston as the backend. When I create a window, it fails at runtime with the following error:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:323
stack backtrace:
   1:     0x560fcdd4bb8a - std::sys::imp::backtrace::tracing::imp::write::h917062bce4ff48c3
   2:     0x560fcdd4fff2 - std::panicking::default_hook::{{closure}}::h0bacac31b5ed1870
   3:     0x560fcdd4e153 - std::panicking::default_hook::h5897799da33ece67
   4:     0x560fcdd4e821 - std::panicking::rust_panic_with_hook::h109e116a3a861224
   5:     0x560fcdd4e6b4 - std::panicking::begin_panic::hbb38be1379e09df0
   6:     0x560fcdd4e5d9 - std::panicking::begin_panic_fmt::h26713cea9bce3ab0
   7:     0x560fcdd4e567 - rust_begin_unwind
   8:     0x560fcdda7a6d - core::panicking::panic_fmt::hcfbb59eeb7f27f75
   9:     0x560fcdda79a4 - core::panicking::panic::hd383cb12a44b01ff
  10:     0x560fcdc1c791 - <core::option::Option<T>>::unwrap::he2e178bce4e18b28
                        at /tmp/guix-build-rustc-1.14.0.drv-0/rustc-1.14.0/src/libcore/macros.rs:21
  11:     0x560fcdc38192 - glutin::platform::platform::x11::Window::new::h808fc7fdbdf32fbe
                        at /home/geemili/.cargo/registry/src/github.ghproxy.top-1ecc6299db9ec823/glutin-0.7.2/src/platform/linux/x11.rs:117
  12:     0x560fcdc368df - glutin::platform::platform::api_dispatch::Window::new::hd9c0f8a0d5685463
                        at /home/geemili/.cargo/registry/src/github.ghproxy.top-1ecc6299db9ec823/glutin-0.7.2/src/platform/linux/api_dispatch.rs:100
  13:     0x560fcdc3a1b1 - glutin::window::<impl glutin::WindowBuilder<'a>>::build::h0f881d9e17ec5f53
                        at /home/geemili/.cargo/registry/src/github.ghproxy.top-1ecc6299db9ec823/glutin-0.7.2/src/window.rs:224
  14:     0x560fcdbfc6ad - glutin_window::GlutinWindow::new::h9c0d423e0975629d
                        at /home/geemili/.cargo/registry/src/github.ghproxy.top-1ecc6299db9ec823/pistoncore-glutin_window-0.33.0/src/lib.rs:92
  15:     0x560fcdbfef0b - <glutin_window::GlutinWindow as window::BuildFromWindowSettings>::build_from_window_settings::h95898fa2b0a5d85a
                        at /home/geemili/.cargo/registry/src/github.ghproxy.top-1ecc6299db9ec823/pistoncore-glutin_window-0.33.0/src/lib.rs:361
  16:     0x560fcd9bdd9b - window::WindowSettings::build::h92c3d1c420caa90b
                        at /home/geemili/.cargo/registry/src/github.ghproxy.top-1ecc6299db9ec823/pistoncore-window-0.24.0/src/lib.rs:367
  17:     0x560fcd9009e4 - <conrod::backend::piston::window::Window<W> as window::BuildFromWindowSettings>::build_from_window_settings::hff5c41864cf0c585
                        at /home/geemili/.cargo/registry/src/github.ghproxy.top-1ecc6299db9ec823/conrod-0.48.0/./src/backend/piston/window.rs:107
  18:     0x560fcd9bdd5b - window::WindowSettings::build::h6b242ac7900aef2b
                        at /home/geemili/.cargo/registry/src/github.ghproxy.top-1ecc6299db9ec823/pistoncore-window-0.24.0/src/lib.rs:367
  19:     0x560fcd9f74cf - living_graph::main::hf4715fb3c5c20e19
                        at /home/geemili/repo/gogs.geemili.xyz/living_graph/src/main.rs:22
  20:     0x560fcdd5793a - __rust_maybe_catch_panic
  21:     0x560fcdd4f321 - std::rt::lang_start::hd661476ce2fc2931
  22:     0x560fcda16ad2 - main
  23:     0x7fe5bb67929f - __libc_start_main
  24:     0x560fcd900849 - _start
  25:                0x0 - <unknown>

I followed the stack trace to the line of code where it originated; src/platform/linux/x11.rs:117. This is the line:

        let display = get_x11_xconnection().unwrap();

One thing to note is that I am using GuixSD, which doesn't like to put files in the typical places for linux. I don't know if that is the source of the problem.

@icefoxen
Copy link

Can you produce a minimum reproduction program? I'll see if it happens on other linuces.

@leroycep
Copy link
Author

leroycep commented Feb 4, 2017

This is the minimum code I need to produce the panic with glutin 0.7.

extern crate glutin;

fn main() {
    let _window = glutin::WindowBuilder::new().build();
}

@icefoxen
Copy link

icefoxen commented Feb 4, 2017

That's pretty minimal! On Debian Linux Stretch, using Rust 1.15 and glutin 0.7:

  • NVidia NVS 5100M, OpenGL 3.3: works
  • NVidia GTX 660, OpenGL 4.5: works
  • AMD Radeon HD 8400, OpenGL 4.3: works

However, I was able to get the same error at the same place when I accidentally tried to run the program via ssh when there was no display available. This suggests that this is happening because it can't open an X11 display. What is the output of env | grep DISPLAY on your system?

A nicer error message than 'called Option::unwrap() on a None value' might be a good idea though.

@leroycep
Copy link
Author

leroycep commented Feb 4, 2017

The output of env | grep DISPLAY is DISPLAY=:0.0.

This suggests that this is happening because it can't open an X11 display.

I think that this is the reason. I mentioned in the original post that I am using GuixSD. Guix tries to keep dependencies isolated from each other, so perhaps a dynamically linked library that glutin needs isn't there. I've tried including the x11 and mesa libraries in LD_LIBRARY_PATH, but that didn't change anything.

@ayyess
Copy link

ayyess commented Feb 5, 2017

I got this same error on NixOS and was able to get the project to run using

let
   pkgs = import <nixpkgs> {};
in pkgs.stdenv.mkDerivation rec {
  name = "glutin-env";
  LD_LIBRARY_PATH = with pkgs.xlibs; "${pkgs.mesa}/lib:${libX11}/lib:${libXcursor}/lib:${libXxf86vm}/lib:${libXi}/lib";
}

from issue #642. I don't think GuixSD can drop to a nix-shell but you could try including the other libraries in the path (all are required for me).

@leroycep
Copy link
Author

leroycep commented Feb 6, 2017

Thanks for the help! I got it working with

$ guix environment --ad-hoc mesa libx11 libxcursor libxxf86vm libxi
$ env LD_LIBRARY_PATH=$GUIX_ENVIRONMENT/lib cargo run

I had to give glutin a version of OpenGl that it could run, and I can't see anything rendering, but those are separate issues. Thanks! 😄

@leroycep leroycep closed this as completed Feb 6, 2017
@leroycep leroycep changed the title Linux panics with Option::unwrap() GuixSD panics with Option::unwrap() Feb 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants