Skip to content

Creating multiple windows causes crash on Linux #215

@killkrt

Description

@killkrt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions