rio icon indicating copy to clipboard operation
rio copied to clipboard

thread 'main' panicked at /sugarloaf/src/context/mod.rs:100:14

Open 0323pin opened this issue 1 year ago • 12 comments

Last time I've tried rio on NetBSD, it was at version 0.0.34

At the time, I faced this issue, https://github.com/raphamorim/rio/issues/376

Now, that there's v0.1.1, I thought I would try again.

The following three patches are required for it to build on NetBSD:

$NetBSD$

Add NetBSD support.

--- corcovado/src/sys/unix/kqueue.rs.orig	2023-12-10 20:06:10.635526974 +0000
+++ corcovado/src/sys/unix/kqueue.rs
@@ -346,6 +346,7 @@ impl Events {
             #[cfg(any(
                 target_os = "dragonfly",
                 target_os = "freebsd",
+                target_os = "netbsd",
                 target_os = "ios",
                 target_os = "macos"
             ))]
@@ -407,6 +408,7 @@ fn does_not_register_rw() {
 #[cfg(any(
     target_os = "dragonfly",
     target_os = "freebsd",
+    target_os = "netbsd",
     target_os = "ios",
     target_os = "macos"
 ))]
$NetBSD$

Add NetBSD support.

--- corcovado/src/sys/unix/ready.rs.orig	2023-12-10 20:09:23.686406007 +0000
+++ corcovado/src/sys/unix/ready.rs
@@ -98,6 +98,7 @@ const HUP: usize = 0b00_1000;
 #[cfg(any(
     target_os = "dragonfly",
     target_os = "freebsd",
+    target_os = "netbsd",
     target_os = "ios",
     target_os = "macos"
 ))]
@@ -106,6 +107,7 @@ const AIO: usize = 0b01_0000;
 #[cfg(not(any(
     target_os = "dragonfly",
     target_os = "freebsd",
+    target_os = "netbsd",
     target_os = "ios",
     target_os = "macos"
 )))]
@@ -176,6 +178,7 @@ impl UnixReady {
     #[cfg(any(
         target_os = "dragonfly",
         target_os = "freebsd",
+        target_os = "netbsd",
         target_os = "ios",
         target_os = "macos"
     ))]
@@ -186,6 +189,7 @@ impl UnixReady {
     #[cfg(not(any(
         target_os = "dragonfly",
         target_os = "freebsd",
+        target_os = "netbsd",
         target_os = "ios",
         target_os = "macos"
     )))]
@@ -318,6 +322,7 @@ impl UnixReady {
     #[cfg(any(
         target_os = "dragonfly",
         target_os = "freebsd",
+        target_os = "netbsd",
         target_os = "ios",
         target_os = "macos"
     ))]
@@ -330,6 +335,7 @@ impl UnixReady {
     #[cfg(not(any(
         target_os = "dragonfly",
         target_os = "freebsd",
+        target_os = "netbsd",
         target_os = "ios",
         target_os = "macos"
     )))]
$NetBSD$

Add NetBSD support.

--- teletypewriter/src/unix/mod.rs.orig	2023-12-10 19:54:05.309009040 +0000
+++ teletypewriter/src/unix/mod.rs
@@ -29,7 +29,7 @@ use std::sync::Arc;
 const TIOCSWINSZ: libc::c_ulong = 0x5414;
 #[cfg(all(target_os = "linux", target_env = "musl"))]
 const TIOCSWINSZ: libc::c_int = 0x5414;
-#[cfg(target_os = "freebsd")]
+#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
 const TIOCSWINSZ: libc::c_ulong = 0x80087467;
 #[cfg(target_os = "macos")]
 const TIOCSWINSZ: libc::c_ulong = 2148037735;
@@ -288,7 +288,7 @@ pub fn create_termp(utf8: bool) -> libc:
         c_line: 0,
     };
 
-    #[cfg(any(target_os = "macos", target_os = "freebsd"))]
+    #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "netbsd"))]
     let mut term = libc::termios {
         c_iflag: libc::ICRNL | libc::IXON | libc::IXANY | libc::IMAXBEL | libc::BRKINT,
         c_oflag: libc::OPOST | libc::ONLCR,
@@ -306,7 +306,7 @@ pub fn create_termp(utf8: bool) -> libc:
         c_ospeed: Default::default(),
     };
 
-    #[cfg(not(target_os = "freebsd"))]
+    #[cfg(not(any(target_os = "freebsd", target_os = "netbsd")))]
     {
         // Enable utf8 support if requested
         if utf8 {
@@ -400,10 +400,10 @@ pub fn create_pty_with_spawn(
     columns: u16,
     rows: u16,
 ) -> Result<Pty, Error> {
-    #[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
+    #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "netbsd")))]
     let mut is_controling_terminal = true;
 
-    #[cfg(any(target_os = "macos", target_os = "freebsd"))]
+    #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "netbsd"))]
     let is_controling_terminal = true;
 
     let mut main: libc::c_int = 0;
@@ -452,7 +452,7 @@ pub fn create_pty_with_spawn(
         cmd
     };
 
-    #[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
+    #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "netbsd")))]
     {
         // If running inside a flatpak sandbox.
         // Must retrieve $SHELL from outside the sandbox, so ask the host.
@@ -879,9 +879,9 @@ pub fn foreground_process_name(main_fd: 
         pid = shell_pid as libc::pid_t;
     }
 
-    #[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
+    #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "netbsd")))]
     let comm_path = format!("/proc/{}/comm", pid);
-    #[cfg(target_os = "freebsd")]
+    #[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
     let comm_path = format!("/compat/linux/proc/{}/comm", pid);
 
     #[cfg(not(target_os = "macos"))]
@@ -907,9 +907,9 @@ pub fn foreground_process_path(
         pid = shell_pid as libc::pid_t;
     }
 
-    #[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
+    #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "netbsd")))]
     let link_path = format!("/proc/{}/cwd", pid);
-    #[cfg(target_os = "freebsd")]
+    #[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
     let link_path = format!("/compat/linux/proc/{}/cwd", pid);
 
     #[cfg(not(target_os = "macos"))]

Unfortunately, it still won't run :(

thread 'main' panicked at /usr/pkgsrc/wip/rio/work/rio-0.1.1/sugarloaf/src/context/mod.rs:100:14:
Request adapter
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Exception: rio killed by signal abort trap (core dumped)

Setting RUST_BACKTRACE=full doesn't tell me more,

~> set-env RUST_BACKTRACE "full"
~> rio
thread 'main' panicked at /usr/pkgsrc/wip/rio/work/rio-0.1.1/sugarloaf/src/context/mod.rs:100:14:
Request adapter
stack backtrace:
   0:          0x117aad7 - <unknown>
   1:           0xd97d50 - <unknown>
   2:          0x119d09e - <unknown>
   3:          0x117a86d - <unknown>
   4:          0x1194840 - <unknown>
   5:          0x1194527 - <unknown>
   6:          0x1194d79 - <unknown>
   7:          0x117aeca - <unknown>
   8:          0x117acf6 - <unknown>
   9:          0x1194904 - <unknown>
  10:           0xcc5075 - <unknown>
  11:           0xd9c501 - <unknown>
  12:           0xcc54eb - <unknown>
  13:          0x1047b17 - <unknown>
  14:          0x106948a - <unknown>
  15:          0x1061dd2 - <unknown>
  16:           0xfd4143 - <unknown>
Exception: rio killed by signal abort trap (core dumped)

Neither does gdb

~> gdb rio rio.core
GNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64--netbsd".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from rio...
(No debugging symbols found in rio)
[New process 20260]
[New process 17631]
[New process 8626]
[New process 29333]
[New process 15316]
[New process 29538]
[New process 16473]
Core was generated by `rio'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007a5a1a8472aa in ?? ()
[Current thread is 1 (process 20260)]

Of course, as release is built without debugging symbols. But, I need the patches to build the package, so building with cargo only isn't as simple.

ktruss is probably a little more helpful.

[...]
 27681  27681 rio      mmap(0, 0x4000, 0x3, 0x1, 0xf, 0, 0x101069000) = 0x776838e36000
 27681  27681 rio      write(0x2, 0x11ec748, 0x8)  = 8
       "thread '"
 27681  27681 rio      write(0x2, 0x77683cfde008, 0x4) = 4
       "main"
 27681  27681 rio      write(0x2, 0x11ec758, 0xe)  = 14
       "' panicked at "
 27681  27681 rio      write(0x2, 0x117499c, 0x3f) = 63
       "/usr/pkgsrc/wip/rio/work/rio-0.1.1/sugarloaf/src/context/mod.rs"
 27681  27681 rio      write(0x2, 0x10eb890, 0x1)  = 1
       ":"
 27681  27681 rio      write(0x2, 0x7f7fff4b0345, 0x3) = 3
       "100"
 27681  27681 rio      write(0x2, 0x10eb890, 0x1)  = 1
       ":"
 27681  27681 rio      write(0x2, 0x7f7fff4b0346, 0x2) = 2
       "14"
 27681  27681 rio      write(0x2, 0x11ec766, 0x2)  = 2
       ":\n"
 27681  27681 rio      write(0x2, 0x77683bf6a970, 0xf) = 15
       "Request adapter"
 27681  27681 rio      write(0x2, 0x11ec768, 0x1)  = 1
       "\n"
 27681  27681 rio      write(0x2, 0x11ec769, 0x4e) = 78
       "note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n"
 27681  27681 rio      __sigprocmask14(0x3, 0x7f7fff4b05f0, 0) = 0
 27681  27681 rio      _lwp_self()                 = 27681
 27681  27681 rio      _lwp_kill(0x6c21, 0x6)      = 0
 27681  27681 rio      SIGABRT SIG_DFL
 27681  19547 rio      ___lwp_park60               Err#4 EINTR
 27681  21535 rio      ___lwp_park60               Err#4 EINTR
 27681  21786 rio      __kevent100                 Err#4 EINTR
 27681  11658 rio      ___lwp_park60               Err#4 EINTR
 27681  28920 rio      ___lwp_park60               Err#4 EINTR
 27681  11661 rio      ___lwp_park60               Err#4 EINTR

Any thoughts? Thanks!

0323pin avatar Jun 18 '24 12:06 0323pin

So, I've clone the repo locally, applied the above patches and built rio with the debug symbols on. Here's the resulting backtrace:

~> set-env RUST_BACKTRACE "full"
~> rio
thread 'main' panicked at /home/pin/Git/rio/sugarloaf/src/context/mod.rs:100:14:
Request adapter
stack backtrace:
   0:          0x26977c0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h64b379b49e1ac14c
   1:          0x26c62d3 - core::fmt::write::hffad184a3e8a29fd
   2:          0x267ff99 - std::io::Write::write_fmt::h898ad85f5400c6c1
   3:          0x26975a8 - std::sys_common::backtrace::print::hfd142b535fa244a2
   4:          0x2698229 - std::panicking::default_hook::{{closure}}::h0b2841cddcb5179d
   5:          0x2697ef2 - std::panicking::default_hook::hb55ff70a667c0912
   6:          0x2698781 - std::panicking::rust_panic_with_hook::hf0fd20f889dcc3a2
   7:          0x2698626 - std::panicking::begin_panic_handler::{{closure}}::hf70ee2d56df2cd9e
   8:          0x26979d9 - std::sys_common::backtrace::__rust_end_short_backtrace::h2bcae7246dcb03a5
   9:          0x2698377 - rust_begin_unwind
  10:           0x73c6a3 - core::panicking::panic_fmt::h54accd437c2365a4
  11:          0x26c855c - core::panicking::panic_display::h3f559986d8c35394
  12:           0x73c0ec - core::option::expect_failed::hfe05ab716a1704a1
  13:          0x1d7428c - core::option::Option<T>::expect::hf459028b2b901c2b
                               at /usr/pkgsrc/wip/rust179/work/rustc-1.79.0-src/library/core/src/option.rs:895:21
  14:           0x8a01a2 - sugarloaf::context::Context::new::{{closure}}::hdc78f2e28a5ed39b
                               at /home/pin/Git/rio/sugarloaf/src/context/mod.rs:93:23
  15:           0x7e1220 - sugarloaf::sugarloaf::Sugarloaf::new::{{closure}}::h1549472fcadf491d
                               at /home/pin/Git/rio/sugarloaf/src/sugarloaf.rs:120:50
  16:           0x7c470b - rio::screen::Screen::new::{{closure}}::h36417bcfd846877a
                               at /home/pin/Git/rio/frontends/rioterm/src/screen/mod.rs:159:10
  17:           0x88553a - rio::router::RouteWindow::new::{{closure}}::hf5609a978315b9b0
                               at /home/pin/Git/rio/frontends/rioterm/src/router/mod.rs:365:82
  18:           0x80907c - rio::sequencer::Sequencer::run::{{closure}}::hdfceb00f487f15c6
                               at /home/pin/Git/rio/frontends/rioterm/src/sequencer.rs:63:18
  19:           0x8587ea - rio::main::{{closure}}::h1f3516d14b586e2d
                               at /home/pin/Git/rio/frontends/rioterm/src/main.rs:149:50
  20:           0x794e13 - tokio::runtime::park::CachedParkThread::block_on::{{closure}}::h577a4f16ba7f1265
                               at /home/pin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/park.rs:281:63
  21:           0x794c6e - tokio::runtime::coop::with_budget::h88ae03db5d966fac
                               at /home/pin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/coop.rs:107:5
  22:           0x794c6e - tokio::runtime::coop::budget::h0618cc0523b111fa
                               at /home/pin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/coop.rs:73:5
  23:           0x794c6e - tokio::runtime::park::CachedParkThread::block_on::h917c79e45e27046e
                               at /home/pin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/park.rs:281:31
  24:           0x812772 - tokio::runtime::context::blocking::BlockingRegionGuard::block_on::hbd4155abba16ce0a
                               at /home/pin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/context/blocking.rs:66:9
  25:           0x780c79 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}::h32d608fba8768f78
                               at /home/pin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
  26:           0x7f8dc5 - tokio::runtime::context::runtime::enter_runtime::h2a0d130d5b69c2c1
                               at /home/pin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/context/runtime.rs:65:16
  27:           0x780bfa - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::h63782f3a604144f3
                               at /home/pin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
  28:           0x806196 - tokio::runtime::runtime::Runtime::block_on::h2aaf9818535970a6
                               at /home/pin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/runtime.rs:351:45
  29:           0x8d0fda - rio::main::h660e553ea9dbe216
                               at /home/pin/Git/rio/frontends/rioterm/src/main.rs:155:5
  30:           0x748b4b - core::ops::function::FnOnce::call_once::h281b9df121ef66e9
                               at /usr/pkgsrc/wip/rust179/work/rustc-1.79.0-src/library/core/src/ops/function.rs:250:5
  31:           0x804a4e - std::sys_common::backtrace::__rust_begin_short_backtrace::h2e97682ccb8e71b7
                               at /usr/pkgsrc/wip/rust179/work/rustc-1.79.0-src/library/std/src/sys_common/backtrace.rs:155:18
  32:           0x782561 - std::rt::lang_start::{{closure}}::hee1cb4c2a5c3093a
                               at /usr/pkgsrc/wip/rust179/work/rustc-1.79.0-src/library/std/src/rt.rs:159:18
  33:          0x2698267 - std::panicking::try::h89c5172be281790d
  34:          0x26a5938 - std::rt::lang_start_internal::h7cd5c2ba0d56d034
  35:           0x78253a - std::rt::lang_start::hb45a14bffd4e3e5a
                               at /usr/pkgsrc/wip/rust179/work/rustc-1.79.0-src/library/std/src/rt.rs:158:17
  36:           0x8d10ae - main
  37:           0x739375 - ___start
                               at /usr/src/lib/csu/common/crt0-common.c:349:2

Any ideas?

0323pin avatar Jun 25 '24 10:06 0323pin

Thanks for the issue!

Hmmm, would be nice to patch those changes on Rio/"winit fork" as well. Regarding the second error you sent, looks the "Request adapter" couldn't be created, this happens when wgpu cannot create an adapter using vulkan/gl/...

raphamorim avatar Jul 12 '24 10:07 raphamorim

I can make a PR if you would like but, ...

would be nice to patch those changes on Rio/"winit fork" as well.

Where do I find that fork? I didn't see it on the branches you have here at github.

looks the "Request adapter" couldn't be created, this happens when wgpu cannot create an adapter using vulkan/gl/...

NetBSD doesn't have vulkan but, I've tried setting the wgpu environment variable to gl and that didn't help.

0323pin avatar Jul 16 '24 13:07 0323pin

@0323pin

Where do I find that fork? I didn't see it on the branches you have here at github.

It's a directory in the repository. See here.

TornaxO7 avatar Sep 05 '24 23:09 TornaxO7

Cheers @TornaxO7 ... I should have looked.

Also, this made me think about something else.

looks the "Request adapter" couldn't be created, this happens when wgpu cannot create an adapter using vulkan/gl/...

@raphamorim Would you spare me some grep and point me to where exactly the request is being made? Could be a ${PATH} issue. Worth discarding that otherwise.

0323pin avatar Sep 06 '24 05:09 0323pin

@0323pin did you try using the renderer property? https://raphamorim.io/rio/docs/config/renderer

Something like this:

[renderer]
performance = "High"
backend = "GL"

I am curious though because if vulkan leads to error then Rio uses OpenGl as fallback.

raphamorim avatar Sep 06 '24 09:09 raphamorim

Here's the piece of code https://github.com/raphamorim/rio/blob/4623f23b200e82a056391dd39a9eb9ba76027207/sugarloaf/src/context/mod.rs#L93-L132

raphamorim avatar Sep 06 '24 09:09 raphamorim

Does it still crashes?

raphamorim avatar Apr 14 '25 10:04 raphamorim

Does it still crashes?

I would need to check with an up-to-date check-out. Give me a couple of days (latest next week).

0323pin avatar Apr 14 '25 14:04 0323pin

No stress, please take your time

raphamorim avatar Apr 14 '25 14:04 raphamorim

@raphamorim just for the record it might take a bit longer. I had a crash on my dev system and just recovered it, fsck -y did it's job but, I still don't know if there's any permanent damage. Hopefully, only the working directory at the time of crash was corrupted.

0323pin avatar Apr 19 '25 07:04 0323pin

Sorry for the delay, building from git HEAD without any sort of patching fails, cargo build yields:

   Compiling teletypewriter v0.2.13 (/home/pin/Git/rio/teletypewriter)
error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:314:13
    |
314 |             term.c_iflag |= libc::IUTF8;
    |             ^^^^ not found in this scope

error[E0425]: cannot find value `IUTF8` in crate `libc`
   --> teletypewriter/src/unix/mod.rs:314:35
    |
314 |             term.c_iflag |= libc::IUTF8;
    |                                   ^^^^^ not found in `libc`

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:319:5
    |
319 |     term.c_cc[libc::VEOF] = 4;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:320:5
    |
320 |     term.c_cc[libc::VEOL] = 255;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:321:5
    |
321 |     term.c_cc[libc::VEOL2] = 255;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:322:5
    |
322 |     term.c_cc[libc::VERASE] = 0x7f;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:323:5
    |
323 |     term.c_cc[libc::VWERASE] = 23;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:324:5
    |
324 |     term.c_cc[libc::VKILL] = 21;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:325:5
    |
325 |     term.c_cc[libc::VREPRINT] = 18;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:326:5
    |
326 |     term.c_cc[libc::VINTR] = 3;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:327:5
    |
327 |     term.c_cc[libc::VQUIT] = 0x1c;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:328:5
    |
328 |     term.c_cc[libc::VSUSP] = 26;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:329:5
    |
329 |     term.c_cc[libc::VSTART] = 17;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:330:5
    |
330 |     term.c_cc[libc::VSTOP] = 19;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:331:5
    |
331 |     term.c_cc[libc::VLNEXT] = 22;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:332:5
    |
332 |     term.c_cc[libc::VDISCARD] = 15;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:333:5
    |
333 |     term.c_cc[libc::VMIN] = 1;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:334:5
    |
334 |     term.c_cc[libc::VTIME] = 0;
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `term` in this scope
   --> teletypewriter/src/unix/mod.rs:342:5
    |
342 |     term
    |     ^^^^ not found in this scope

error[E0425]: cannot find value `TIOCSWINSZ` in this scope
   --> teletypewriter/src/unix/mod.rs:715:44
    |
715 |         match unsafe { libc::ioctl(**self, TIOCSWINSZ, &winsize as *const _) } {
    |                                            ^^^^^^^^^^ not found in this scope
    |
help: consider importing this constant
    |
9   + use libc::TIOCSWINSZ;
    |

For more information about this error, try `rustc --explain E0425`.
error: could not compile `teletypewriter` (lib) due to 20 previous errors

I see NetBSD has been added to corcovado/src/sys/unix/kqueue.rs. Although, I don't see it as a target in corcovado/src/sys/unix/ready.rs or teletypewriter/src/unix/mod.rs.

Patching teletypewritter as follows,

--- mod.rs.orig	2025-04-26 13:20:35.000133447 +0200
+++ mod.rs	2025-04-26 13:26:33.998973699 +0200
@@ -30,7 +30,7 @@
 const TIOCSWINSZ: libc::c_ulong = 0x5414;
 #[cfg(all(target_os = "linux", target_env = "musl"))]
 const TIOCSWINSZ: libc::c_int = 0x5414;
-#[cfg(target_os = "freebsd")]
+#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
 const TIOCSWINSZ: libc::c_ulong = 0x80087467;
 #[cfg(target_os = "macos")]
 const TIOCSWINSZ: libc::c_ulong = 2148037735;
@@ -289,7 +289,7 @@
         c_line: 0,
     };
 
-    #[cfg(any(target_os = "macos", target_os = "freebsd"))]
+    #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "netbsd"))]
     let mut term = libc::termios {
         c_iflag: libc::ICRNL | libc::IXON | libc::IXANY | libc::IMAXBEL | libc::BRKINT,
         c_oflag: libc::OPOST | libc::ONLCR,
@@ -307,7 +307,7 @@
         c_ospeed: Default::default(),
     };
 
-    #[cfg(not(target_os = "freebsd"))]
+    #[cfg(not(any(target_os = "freebsd", target_os = "netbsd")))]
     {
         // Enable utf8 support if requested
         if utf8 {
@@ -401,10 +401,10 @@
     columns: u16,
     rows: u16,
 ) -> Result<Pty, Error> {
-    #[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
+    #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "netbsd")))]
     let mut is_controling_terminal = true;
 
-    #[cfg(any(target_os = "macos", target_os = "freebsd"))]
+    #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "netbsd"))]
     let is_controling_terminal = true;
 
     let mut main: libc::c_int = 0;
@@ -453,7 +453,7 @@
         cmd
     };
 
-    #[cfg(not(any(target_os = "macos", target_os = "freebsd")))]
+    #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "netbsd")))]
     {
         // If running inside a flatpak sandbox.
         // Must retrieve $SHELL from outside the sandbox, so ask the host.

allows the build to complete with a couple of warnings which, I'd guess you are aware of.

warning: creating a shared reference to mutable static is discouraged
   --> rio-window/src/platform_impl/linux/mod.rs:664:30
    |
664 |         for hook in unsafe { XLIB_ERROR_HOOKS.lock() }.unwrap().iter() {
    |                              ^^^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
    = note: `#[warn(static_mut_refs)]` on by default

warning: creating a shared reference to mutable static is discouraged
  --> rio-window/src/platform/x11.rs:82:9
   |
82 | /         crate::platform_impl::XLIB_ERROR_HOOKS
83 | |             .lock()
   | |___________________^ shared reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

   Compiling teletypewriter v0.2.13 (/home/pin/Git/rio/teletypewriter)
warning: unused variable: `utf8`
   --> teletypewriter/src/unix/mod.rs:265:21
    |
265 | pub fn create_termp(utf8: bool) -> libc::termios {
    |                     ^^^^ help: if this is intentional, prefix it with an underscore: `_utf8`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: `teletypewriter` (lib) generated 1 warning

There's also a build warning for rio-backend,

warning: method `overwrite_with_platform_config` is never used
   --> rio-backend/src/config/mod.rs:468:8
    |
252 | impl Config {
    | ----------- method in this implementation
...
468 |     fn overwrite_with_platform_config(&mut self, platform_config: PlatformConfig) {
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: `rio-backend` (lib) generated 1 warning

Note that the patch to teletypewriter is slightly different from the one in the original post. NetBSD does have /proc, so I did not patch those code sections this time.

But, running the binary still does not work :(

~> ./target/debug/rio

thread 'main' panicked at /home/pin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wgpu-25.0.0/src/api/instance.rs:117:13:
No wgpu backend feature that is implemented for the target platform was enabled. See `wgpu::Instance::enabled_backend_features()` for more information.

Even setting WGPU_BACKEND to gl doesn't help and I get the same panic.

0323pin avatar Apr 26 '25 11:04 0323pin