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

Creating multiple windows causes crash on Linux #215

Open
killkrt opened this issue Oct 22, 2017 · 8 comments
Open

Creating multiple windows causes crash on Linux #215

killkrt opened this issue Oct 22, 2017 · 8 comments

Comments

@killkrt
Copy link

killkrt commented Oct 22, 2017

Hi,

I am trying to create an application that needs to open multiple windows.
I've tried to implement a simple test, and it is perfectly working under macOS 10.12.6, but it is causing crashes under Linux (tried on two different PC).

This is the little test:

extern crate piston_window;

use piston_window::*;

fn main() {
    let mut window1: PistonWindow =
        WindowSettings::new("Window 1", (640, 480))
            .exit_on_esc(true)
            .build()
            .unwrap_or_else(|e| panic!("Failed to build PistonWindow: {}", e));

    let mut window2: PistonWindow =
        WindowSettings::new("Window 2", (640, 480))
            .exit_on_esc(true)
            .build()
            .unwrap_or_else(|e| panic!("Failed to build PistonWindow: {}", e));

    println!("Windows are ready.");

    while let (Some(e), Some(f)) = (window1.next(), window2.next()) {
        window1.draw_2d(&e, |c, g| {
            clear([0.5, 1.0, 0.5, 1.0], g);
            Line::new([1.0, 0.0, 0.0, 1.0], 1.0).draw(
                [1.0, 1.0, 100.0, 100.0],
                &c.draw_state,
                c.transform,
                g,
            );
        });

        window2.draw_2d(&f, |c, g| {
            clear([0.0, 0.0, 0.0, 1.0], g);
            Line::new([1.0, 1.0, 1.0, 1.0], 1.0).draw(
                [
                    1.0,
                    100.0,
                    100.0,
                    100.0,
                ],
                &c.draw_state,
                c.transform,
                g,
            );
        });
    }
}

It is crashing with the following output:

Windows are ready.                                                                         
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libc
ore/option.rs:335:20                                                                       
note: Run with `RUST_BACKTRACE=1` for a backtrace.                                         
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inne
r: .. }"', /checkout/src/libcore/result.rs:906:4                                           
stack backtrace:                                                                           
   0:     0x563ec1b71593 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::hfc798
5b08e763a82                                                                                
                               at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:
49                                                                                         
   1:     0x563ec1b6dcb4 - std::sys_common::backtrace::_print::h16a1db02a59ead63           
                               at /checkout/src/libstd/sys_common/backtrace.rs:71          
   2:     0x563ec1b736a3 - std::panicking::default_hook::{{closure}}::h48ecee46f2eefc30    
                               at /checkout/src/libstd/sys_common/backtrace.rs:60          
                               at /checkout/src/libstd/panicking.rs:381                    
   3:     0x563ec1b73412 - std::panicking::default_hook::hb4c92ae8d005ca44                 
                               at /checkout/src/libstd/panicking.rs:397                    
   4:     0x563ec1b73b67 - std::panicking::rust_panic_with_hook::h25d461655d60b1a5         
                               at /checkout/src/libstd/panicking.rs:611                    
   5:     0x563ec1b739c4 - std::panicking::begin_panic::h0f6fdd9abfd7dfb9                  
                               at /checkout/src/libstd/panicking.rs:572                    
   6:     0x563ec1b73939 - std::panicking::begin_panic_fmt::ha31e26b280c9e878              
                               at /checkout/src/libstd/panicking.rs:522                    
   7:     0x563ec1b738ca - rust_begin_unwind                                               
                               at /checkout/src/libstd/panicking.rs:498
   8:     0x563ec1baab20 - core::panicking::panic_fmt::h67504914198d0451
                               at /checkout/src/libcore/panicking.rs:71
   9:     0x563ec19dbb8c - core::result::unwrap_failed::hd65272d54dcb40d7
                               at /checkout/src/libcore/macros.rs:41
  10:     0x563ec19c140b - <core::result::Result<T, E>>::unwrap::h1eb5b5ccd0fbc6c6
                               at /checkout/src/libcore/result.rs:772
  11:     0x563ec1a0e166 - <winit::platform::platform::x11::Window as core::ops::drop::Drop
>::drop::h6ea208e21e0a7c7c
                               at /home/killkrt/.cargo/registry/src/github.com-1ecc6299db9e
c823/winit-0.8.3/src/platform/linux/x11/mod.rs:757
  12:     0x563ec187f7a4 - core::ptr::drop_in_place::h0163eb92688d0bf1
                               at /checkout/src/libcore/ptr.rs:61
  13:     0x563ec18827cf - core::ptr::drop_in_place::h95dbf5c3c6fda0a7
                               at /checkout/src/libcore/ptr.rs:61
  14:     0x563ec1882844 - core::ptr::drop_in_place::h984fba453a85a027
                               at /checkout/src/libcore/ptr.rs:61
  15:     0x563ec18817b1 - core::ptr::drop_in_place::h63c6b9d227344056
                               at /checkout/src/libcore/ptr.rs:61
  16:     0x563ec1882eb4 - core::ptr::drop_in_place::ha581a6d94c2a5c25
                               at /checkout/src/libcore/ptr.rs:61
  17:     0x563ec18838e4 - core::ptr::drop_in_place::hba1fa1f685452564
                               at /checkout/src/libcore/ptr.rs:61
  18:     0x563ec18e0056 - test_2d::main::h783d9d5693e74edf
                               at src/main.rs:46
  19:     0x563ec1b7aa6c - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:99
  20:     0x563ec1b7428b - std::rt::lang_start::hdcba96cc6d0f043d
                               at /checkout/src/libstd/panicking.rs:459
                               at /checkout/src/libstd/panic.rs:361
                               at /checkout/src/libstd/rt.rs:61
  21:     0x563ec18e10c2 - main
  22:     0x7fa7f4936f69 - __libc_start_main
  23:     0x563ec1859539 - _start
  24:                0x0 - <unknown>
thread panicked while panicking. aborting.
[1]    27653 illegal hardware instruction (core dumped)  cargo run

I can guess that is something related to X11, but I would like to understand how to solve this problem.

System info:
macOS 10.12.6: rust 1.21 stable
Linux (Arch Linux: 4.13.7-1-ARCH #1 SMP PREEMPT Sat Oct 14 20:13:26 CEST 2017 x86_64 GNU/Linux): rust 1.21 stable
Video card: nVidia GeForce GTX 970 (NVRM version: NVIDIA UNIX x86_64 Kernel Module 387.12)
CPU: Intel i7 6700K

@bvssvni
Copy link
Member

bvssvni commented Oct 22, 2017

Can you try with PistonWindow<Sdl2Window> (from the sdl2_window backend)?

@killkrt
Copy link
Author

killkrt commented Oct 22, 2017

Tried, but with no luck:

thread 'main' panicked at 'Failed to build PistonWindow: Cannot initialize `Sdl` more than once at a time.', src/main.rs:18:32

@bvssvni
Copy link
Member

bvssvni commented Oct 22, 2017

@killkrt
Copy link
Author

killkrt commented Oct 22, 2017

It is still crashing:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', /checkout/src/libcore/result.rs:906:4                                                                        
stack backtrace:                                                                                                                                                                                                   
   0:     0x5632479ed063 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::hfc7985b08e763a82                                                                                                             
                               at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49                                                                                                                      
   1:     0x5632479e9784 - std::sys_common::backtrace::_print::h16a1db02a59ead63                                                                                                                                   
                               at /checkout/src/libstd/sys_common/backtrace.rs:71                                                                                                                                  
   2:     0x5632479ef173 - std::panicking::default_hook::{{closure}}::h48ecee46f2eefc30                                                                                                                            
                               at /checkout/src/libstd/sys_common/backtrace.rs:60
                               at /checkout/src/libstd/panicking.rs:381
   3:     0x5632479eeee2 - std::panicking::default_hook::hb4c92ae8d005ca44
                               at /checkout/src/libstd/panicking.rs:397
   4:     0x5632479ef637 - std::panicking::rust_panic_with_hook::h25d461655d60b1a5
                               at /checkout/src/libstd/panicking.rs:611
   5:     0x5632479ef494 - std::panicking::begin_panic::h0f6fdd9abfd7dfb9
                               at /checkout/src/libstd/panicking.rs:572
   6:     0x5632479ef409 - std::panicking::begin_panic_fmt::ha31e26b280c9e878
                               at /checkout/src/libstd/panicking.rs:522
   7:     0x5632479ef39a - rust_begin_unwind
                               at /checkout/src/libstd/panicking.rs:498
   8:     0x563247a265f0 - core::panicking::panic_fmt::h67504914198d0451
                               at /checkout/src/libcore/panicking.rs:71
   9:     0x5632478591ec - core::result::unwrap_failed::hd65272d54dcb40d7
                               at /checkout/src/libcore/macros.rs:41
  10:     0x56324783ea6b - <core::result::Result<T, E>>::unwrap::h1eb5b5ccd0fbc6c6
                               at /checkout/src/libcore/result.rs:772
  11:     0x56324788b946 - <winit::platform::platform::x11::Window as core::ops::drop::Drop>::drop::h6ea208e21e0a7c7c
                               at /home/killkrt/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.8.3/src/platform/linux/x11/mod.rs:757
  12:     0x56324770d1a4 - core::ptr::drop_in_place::h5bfd7a85b62a391b
                               at /checkout/src/libcore/ptr.rs:61
  13:     0x56324770de5f - core::ptr::drop_in_place::h866b4f4846de09c0
                               at /checkout/src/libcore/ptr.rs:61
  14:     0x56324770e134 - core::ptr::drop_in_place::h89440f16549f1821
                               at /checkout/src/libcore/ptr.rs:61
  15:     0x56324770f691 - core::ptr::drop_in_place::hcae5eb4794c2e027
                               at /checkout/src/libcore/ptr.rs:61
  16:     0x56324770f6b4 - core::ptr::drop_in_place::hcb97cdbe3465ef35
                               at /checkout/src/libcore/ptr.rs:61
  17:     0x56324770f854 - core::ptr::drop_in_place::hccf3e6fbb75a8442
                               at /checkout/src/libcore/ptr.rs:61
  18:     0x56324770dde3 - core::ptr::drop_in_place::h85a102cfbb1be414
                               at /checkout/src/libcore/ptr.rs:61
  19:     0x563247723fb1 - <alloc::vec::Vec<T> as core::ops::drop::Drop>::drop::h034e4def82e51459
                               at /checkout/src/liballoc/vec.rs:2105
  20:     0x5632477106e4 - core::ptr::drop_in_place::hef157eb1159f9c52
                               at /checkout/src/libcore/ptr.rs:61
  21:     0x56324775dfcb - multiple_windows::main::h42c500b41788bf96
                               at src/main.rs:40
  22:     0x5632479f653c - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:99
  23:     0x5632479efd5b - std::rt::lang_start::hdcba96cc6d0f043d
                               at /checkout/src/libstd/panicking.rs:459
                               at /checkout/src/libstd/panic.rs:361
                               at /checkout/src/libstd/rt.rs:61
  24:     0x56324775e632 - main
  25:     0x7f83cc646f69 - __libc_start_main
  26:     0x5632476e5d69 - _start
  27:                0x0 - <unknown>
thread panicked while panicking. aborting.
[1]    10031 illegal hardware instruction (core dumped)  cargo run

@bvssvni
Copy link
Member

bvssvni commented Oct 22, 2017

@kvark Do you have any idea what this is?

@killkrt
Copy link
Author

killkrt commented Oct 23, 2017

Just for your information it is working on Windows 10 (on a Dell laptop Latitude 5480 with i5-6300U).

Anyway I was thinking that "illegal hardware instruction" is quite a weird error! 😕

@bvssvni
Copy link
Member

bvssvni commented Oct 23, 2017

"illegal hardware instruction" could mean this is a compiler bug.

@kvark
Copy link
Member

kvark commented Nov 11, 2017

@bvssvni looks to be happening in the winit's X11 window destructor. PoisonError is for mutex being locked twice without unlocking. I suggest filing an issue to winit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants