tmerr / i3ipc-rs

A Rust library for controlling i3-wm through its IPC interface
MIT License
106 stars 33 forks source link

Unreachable code error when subscribing to Subscription::Workspace #1

Closed mattiasnilsen closed 8 years ago

mattiasnilsen commented 8 years ago

When running the following code, a runtime error is generated, included below.

use i3ipc::I3EventListener;
use i3ipc::Subscription;
use i3ipc::event::Event;

fn main() {
    let mut listener = I3EventListener::connect().unwrap();
    let subs = [Subscription::Workspace];
    listener.subscribe(&subs).unwrap();

    for event in listener.listen() {
    }
}
thread '<main>' panicked at 'internal error: entered unreachable code', /home/kerp/.cargo/registry/src/github.com-88ac128001ac3a9a/i3ipc-0.4.0/src/common.rs:38
stack backtrace:
   1:     0x55565ae3f1d0 - sys::backtrace::tracing::imp::write::h09d7a562cdce3ef9Xcv
   2:     0x55565ae431db - panicking::default_handler::_$u7b$$u7b$closure$u7d$$u7d$::closure.44519
   3:     0x55565ae42e48 - panicking::default_handler::hf7fdb8082bcb0f80lSz
   4:     0x55565ae35a3c - sys_common::unwind::begin_unwind_inner::hfa667eeafdcc5750g1t
   5:     0x55565adf1627 - sys_common::unwind::begin_unwind::h11005261735870655457
                        at src/libstd/sys/common/unwind/mod.rs:219
   6:     0x55565ae2302e - common::build_tree::h96a7d8fb1d22d801Uba
                        at /home/kerp/projects/rust/testproject/<std macros>:3
   7:     0x55565ae2586a - common::build_tree::_$u7b$$u7b$closure$u7d$$u7d$::closure.10324
                        at /home/kerp/.cargo/registry/src/github.com-88ac128001ac3a9a/i3ipc-0.4.0/src/common.rs:13
   8:     0x55565ae25843 - ops::impls::_&'a mut F.FnOnce<A>::call_once::h8679080268370381870
                        at src/libcore/ops.rs:1708
   9:     0x55565ae257e0 - option::Option<T>::map::h6160316823303540631
                        at src/libcore/option.rs:390
  10:     0x55565ae2577e - iter::Map<I, F>.Iterator::next::h6949550101614501572
                        at src/libcore/iter.rs:3342
  11:     0x55565ae253d3 - vec::Vec<T>.FromIterator<T>::from_iter::h6849771975379282085
                        at src/libcollections/vec.rs:1292
  12:     0x55565ae25369 - iter::Iterator::collect::h5970782354055407510
                        at src/libcore/iter.rs:1490
  13:     0x55565ae22761 - common::build_tree::h96a7d8fb1d22d801Uba
                        at /home/kerp/.cargo/registry/src/github.com-88ac128001ac3a9a/i3ipc-0.4.0/src/common.rs:10
  14:     0x55565adfbfd5 - event::WorkspaceEventInfo.FromStr::from_str::h52100c93567f9292S1a
                        at /home/kerp/.cargo/registry/src/github.com-88ac128001ac3a9a/i3ipc-0.4.0/src/event.rs:48
  15:     0x55565adf8ea1 - EventIterator<'a>.Iterator::next::build_event::h65c8a9849ad9db34kzb
                        at /home/kerp/.cargo/registry/src/github.com-88ac128001ac3a9a/i3ipc-0.4.0/src/lib.rs:174
  16:     0x55565adf8b8a - EventIterator<'a>.Iterator::next::h4c53229dde1206d7bzb
                        at /home/kerp/.cargo/registry/src/github.com-88ac128001ac3a9a/i3ipc-0.4.0/src/lib.rs:189
  17:     0x55565adeb5f3 - main::h51b6e621fe2aa0d9iaa
                        at src/main.rs:11
  18:     0x55565ae42aa4 - sys_common::unwind::try::try_fn::h17697512651770205889
  19:     0x55565ae3e5cb - __rust_try
  20:     0x55565ae4253b - rt::lang_start::h5628b9e1fb87c585rKz
  21:     0x55565adeec19 - main
  22:     0x7f283e91b740 - __libc_start_main
  23:     0x55565adeb3a8 - _start
  24:                0x0 - <unknown>
`

I Tested a few other events and they seem to work fine, I haven't tested all of them, though.
tmerr commented 8 years ago

Hi @Kerp1, thanks for the report. The code runs without errors on my machine with i3 version 4.12. Which version are you using?

mattiasnilsen commented 8 years ago

I'm also running version 4.1.2

i3 version 4.12 (2016-03-06, branch "4.12") © 2009 Michael Stapelberg and contributors

When looking a bit closer at the problem, it seems that the response to the border setting for me is "pixel" and not "1pixel" as is expected.

tmerr commented 8 years ago

Yup i3's documentation and code disagreed. https://github.com/i3/i3/issues/2361 Sounds like they've settled on "pixel" being the correct response. Fix incoming