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

fatal runtime error: IO Safety violation: owned file descriptor already closed #18

Closed
tukanoidd opened this issue May 2, 2024 · 7 comments · Fixed by #20
Closed

fatal runtime error: IO Safety violation: owned file descriptor already closed #18

tukanoidd opened this issue May 2, 2024 · 7 comments · Fixed by #20

Comments

@tukanoidd
Copy link

Hey, been trying to set the term view up but have been getting the error in the title. Coredump isn't helpful unfortunately, core rendering stuff and stacktrace im too dumb to decipher (pointers to memory in the binary im assuming, but idk how that would help in current situation), and RUST_BACKTRACE=full doesnt show anything either. I'm pretty much following the examples, i create and store Term in App in new() and pass reference to it from &self to term_view() in view(), check for events in update(), closing window on Shutdown request, and doing the subscription thing as well.

My theory is that the Fd gets dropped unexpectedly at some point but I can't figure out why since judging by the code (at first glance at least) and types used to store the Fd, it shouldn't happen? Mb I'm blind and missing some crucial step required to keep the descriptor alive, but as i said before, semantically my logic for handling Term is identical to the examples.

I will say that I don't store settings in App, but just generate them in separate function to immediately pass them to Term constructor (I'm planning to make some customizable behavior for opening new terminals, so i wanna generalize it under one function), which will get returned from said external function upon initialization. But I don't think this would cause the issue right?

Does Rust stable/nightly matter? (I'm on nightly 2024-05-01). Also, in case it's useful, I'n on NixOS, using nix-cargo-integration flake template, with dependencies to run the application set up (checked before termview was added).

I thought that maybe it could've been alacritty crate that's at fault but I didn't find any issues regarding this error in their repo.

Thanks in advance!

@tukanoidd
Copy link
Author

I just remembered another detail: before i added update and subscription checks, the app wasn't crashing, but the container that was supposed to hold the term view was empty.

@tukanoidd
Copy link
Author

tukanoidd commented May 2, 2024

Ok, never mind, seems to be a NixOS devshell issue, cuz I just tried running it with nix run and it worked. I guess I need to figure this out on my own. Sorry for disturbing.

@tukanoidd
Copy link
Author

Ok, no, it seems to be debug vs release builld issue, i tried running dev build through nix to check debug logs and was greeted witht the same error. On release builds it doesn't crash, but it is incredibly slow, my shell (nushell), isnt able to start up properly, it just hangs there, while other ui components are responsive. I'll try forcing it to be bash to see if that's related to my shell breaking the widget somehow.

@tukanoidd tukanoidd reopened this May 2, 2024
@tukanoidd
Copy link
Author

Bash works fine in release mode (I guess my nushell config does something the widget can't handle, that's on me), but it still crashes in debug mode.

@tukanoidd
Copy link
Author

Just tried switching to stable... and it works. I guess I managed to find a compiler bug XD. Sorry again for disturbing.

@hkoosha
Copy link

hkoosha commented Jul 28, 2024

Looking at the core dump, it does seem to be coming from Alacritty. It's fixed (but I think not released to crates.io yet): alacritty/alacritty#7996

Core dump
$ cargo run -p full_screen
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/full_screen`
fatal runtime error: IO Safety violation: owned file descriptor already closed
Aborted (core dumped)

$ coredumpctl --debugger=gdb debug target/debug/full_screen
(gdb) bt
#0  0x00007fce53a1ae44 in ?? () from /usr/lib/libc.so.6
#1  0x00007fce539c2a30 in raise () from /usr/lib/libc.so.6
#2  0x00007fce539aa4c3 in abort () from /usr/lib/libc.so.6
#3  0x000061545dc374ea in std::sys::pal::unix::abort_internal () at library/std/src/sys/pal/unix/mod.rs:366
#4  0x000061545ce36563 in std::sys::pal::unix::fs::debug_assert_fd_is_open (fd=68) at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/std/src/rt.rs:43
#5  0x000061545ce35555 in std::os::fd::owned::{impl#7}::drop (self=0x7fff5a5af29c) at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/std/src/os/fd/owned.rs:181
#6  0x000061545ce369fa in core::ptr::drop_in_place<std::os::fd::owned::OwnedFd> () at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ptr/mod.rs:542
#7  0x000061545c73ff3b in core::ptr::drop_in_place<std::sys::pal::unix::fd::FileDesc> () at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ptr/mod.rs:542
#8  0x000061545c7406dc in core::ptr::drop_in_place<std::sys::pal::unix::process::process_common::Stdio> () at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ptr/mod.rs:542
#9  0x000061545c73f6e2 in core::ptr::drop_in_place<core::option::Option<std::sys::pal::unix::process::process_common::Stdio>> () at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ptr/mod.rs:542
#10 0x000061545c7409a2 in core::ptr::drop_in_place<std::sys::pal::unix::process::process_common::Command> () at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ptr/mod.rs:542
#11 0x000061545c73fe7b in core::ptr::drop_in_place<std::process::Command> () at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ptr/mod.rs:542
#12 0x000061545c748444 in alacritty_terminal::tty::unix::new (config=0x7fff5a5af840, window_size=..., window_id=0) at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/alacritty_terminal-0.22.0/src/tty/unix.rs:296
#13 0x000061545c6feb3e in iced_term::backend::Backend::new (id=0, event_sender=..., settings=..., font_size=...) at src/backend/mod.rs:149
#14 0x000061545c6b7d67 in iced_term::term::Term::update (self=<error reading variable: That operation is not available on integers of more than 8 bytes.>, cmd=...) at src/term.rs:141
#15 0x000061545c608137 in full_screen::{impl#0}::update (self=<error reading variable: That operation is not available on integers of more than 8 bytes.>, message=...) at examples/full_screen/src/main.rs:77
#16 0x000061545c671906 in iced::application::{impl#0}::update<full_screen::App> (self=<error reading variable: That operation is not available on integers of more than 8 bytes.>, message=<error reading variable: Cannot access memory at address 0x6>)
    at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iced-0.12.0/src/application.rs:227
#17 0x000061545c547c48 in iced_winit::application::update::{closure#0}<iced::application::Instance<full_screen::App>, iced_renderer::compositor::Compositor, tokio::runtime::runtime::Runtime> ()
    at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_winit-0.12.0/src/application.rs:637
#18 0x000061545c63e132 in iced_futures::backend::native::tokio::{impl#0}::enter<iced_runtime::command::Command<full_screen::Message>, iced_winit::application::update::{closure_env#0}<iced::application::Instance<full_screen::App>, iced_renderer::compositor::Compositor, tokio::runtime::runtime::Runtime>> (self=0x61546b0fbec0, f=...) at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_futures-0.12.0/src/backend/native/tokio.rs:19
#19 0x000061545c53f826 in iced_futures::runtime::Runtime<tokio::runtime::runtime::Runtime, iced_winit::proxy::Proxy<full_screen::Message>, full_screen::Message>::enter<tokio::runtime::runtime::Runtime, iced_winit::proxy::Proxy<full_screen::Message>, full_screen::Message, iced_runtime::command::Command<full_screen::Message>, iced_winit::application::update::{closure_env#0}<iced::application::Instance<full_screen::App>, iced_renderer::compositor::Compositor, tokio::runtime::runtime::Runtime>> (self=0x61546b0fbec0, f=<error reading variable: Cannot access memory at address 0x6>)
    at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_futures-0.12.0/src/runtime.rs:51
#20 0x000061545c547a76 in iced_winit::application::update<iced::application::Instance<full_screen::App>, iced_renderer::compositor::Compositor, tokio::runtime::runtime::Runtime> (application=<error reading variable: That operation is not available on integers of more than 8 bytes.>, 
    compositor=0x61546b0fb4d0, surface=0x61546b0fc1f8, cache=0x7fff5a5ba8b8, state=0x61546b0fbf80, renderer=0x61546b0fb5b0, runtime=0x61546b0fbec0, clipboard=0x61546b0fc060, should_exit=0x61546b0fc2bc, proxy=0x61546b0fbf60, debug=0x61546b0fc2bb, messages=0x61546b0fc298, window=0x61546a46e230)
    at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_winit-0.12.0/src/application.rs:637
#21 0x000061545c5453b4 in iced_winit::application::run_instance::{async_fn#0}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor> ()
    at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_winit-0.12.0/src/application.rs:524
#22 0x000061545c5476c2 in iced_winit::application::run::{closure#1}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor> (event=..., event_loop=0x61546a4a8510)
    at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_winit-0.12.0/src/application.rs:224
#23 0x000061545c547caf in core::ops::function::impls::{impl#3}::call_mut<(winit::event::Event<full_screen::Message>, &winit::event_loop::EventLoopWindowTarget<full_screen::Message>), iced_winit::application::run::{closure_env#1}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor>> (self=0x7fff5a5bc038, args=...) at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ops/function.rs:294
#24 0x000061545c547d0f in core::ops::function::impls::{impl#3}::call_mut<(winit::event::Event<full_screen::Message>, &winit::event_loop::EventLoopWindowTarget<full_screen::Message>), &mut iced_winit::application::run::{closure_env#1}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor>> (self=0x7fff5a5bbe00, args=...) at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ops/function.rs:294
#25 0x000061545c66cfd9 in winit::platform_impl::platform::x11::EventLoop<full_screen::Message>::single_iteration<full_screen::Message, &mut &mut iced_winit::application::run::{closure_env#1}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor>> (self=0x7fff5a5bc470, callback=0x7fff5a5bbe00, cause=...) at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/x11/mod.rs:620
#26 0x000061545c66d8b4 in winit::platform_impl::platform::x11::EventLoop<full_screen::Message>::poll_events_with_timeout<full_screen::Message, &mut &mut iced_winit::application::run::{closure_env#1}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor>> (self=0x7fff5a5bc470, timeout=..., callback=0x7fff5a5bc038) at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/x11/mod.rs:547
#27 0x000061545c66a9af in winit::platform_impl::platform::x11::EventLoop<full_screen::Message>::pump_events<full_screen::Message, &mut iced_winit::application::run::{closure_env#1}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor>> (self=0x7fff5a5bc470, timeout=..., callback=0x7fff5a5c6c20) at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/x11/mod.rs:453
#28 0x000061545c66b475 in winit::platform_impl::platform::x11::EventLoop<full_screen::Message>::run_on_demand<full_screen::Message, iced_winit::application::run::{closure_env#1}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor>> (self=0x7fff5a5bc470, event_handler=...) at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/x11/mod.rs:414
#29 0x000061545c55166e in winit::platform_impl::platform::EventLoop<full_screen::Message>::run_on_demand<full_screen::Message, iced_winit::application::run::{closure_env#1}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor>>
    (self=0x7fff5a5bc470, callback=...) at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/mod.rs:821
#30 0x000061545c551da6 in winit::platform_impl::platform::EventLoop<full_screen::Message>::run<full_screen::Message, iced_winit::application::run::{closure_env#1}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor>> (
    self=<error reading variable: Cannot access memory at address 0x12212>, callback=<error reading variable: Cannot access memory at address 0x2e>) at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/linux/mod.rs:814
#31 0x000061545c62ff09 in winit::event_loop::EventLoop<full_screen::Message>::run<full_screen::Message, iced_winit::application::run::{closure_env#1}<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor>> (self=..., 
    event_handler=...) at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/event_loop.rs:249
#32 0x000061545c5470eb in iced_winit::application::run<iced::application::Instance<full_screen::App>, tokio::runtime::runtime::Runtime, iced_renderer::compositor::Compositor> (settings=..., compositor_settings=...)
    at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_winit-0.12.0/src/application.rs:239
#33 0x000061545c622faf in iced::application::Application::run<full_screen::App> (settings=...) at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iced-0.12.0/src/application.rs:208
#34 0x000061545c607c09 in full_screen::main () at examples/full_screen/src/main.rs:10


@Harzu
Copy link
Owner

Harzu commented Jul 28, 2024

Looking at the core dump, it does seem to be coming from Alacritty. It's fixed (but I think not released to crates.io yet): alacritty/alacritty#7996
Core dump

Yep, I'm waiting for this fix will be appeared in crates.io (zed is also waiting).

I can add version from target commit (like zed does).

@Harzu Harzu reopened this Jul 29, 2024
@Harzu Harzu linked a pull request Aug 18, 2024 that will close this issue
@Harzu Harzu closed this as completed in #20 Aug 18, 2024
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

Successfully merging a pull request may close this issue.

3 participants