pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Curious shells/nushell issue



On Thu, 28 Dec 2023 at 21:28, Chavdar Ivanov <ci4ic4%gmail.com@localhost> wrote:
>
> On Thu, 28 Dec 2023 at 14:50, RVP <rvp%sdf.org@localhost> wrote:
> >
> > > On -current, both amd64 and aarch64, using nushell 87.1 and 88.1, I get:
> > > ---
> > > # RUST_BACKTRACE=full /usr/pkg/bin/nu -c "cd /; ls -l "
> > > thread 'main' panicked at library/std/src/sys/unix/time.rs:77:9:
> > > assertion failed: tv_nsec >= 0 && tv_nsec < NSEC_PER_SEC as i64
> >
> > On NetBSD vnode times (esp. birthtimes) are initialized to tv_sec = -1,
> > tv_nsec = -1. FreeBSD does tv_sec = -1, tv_nsec = 0 instead. That's why
> > this assertion's tripping on NetBSD (does rust/nushell read birthtime???).
> >
> > Try patching Rust like this (warning: monkey see, monkey do Rust):
> >
> > In rust/library/std/src/sys/unix/time.rs:
> > const fn new(tv_sec: i64, tv_nsec: i64) -> Timespec {
> >         ...stuff...
> >
> >         #[cfg(target_os = "netbsd")]
> >         let tv_nsec = if (tv_nsec < 0) { 0 } else { tv_nsec };
> >
> >         ...more stuff...
> > }
>
> --- ./work/rustc-1.73.0-src/library/std/src/sys/unix/time.rs.ORIG
>  2023-12-28 17:38:55.059412516 +0000
> +++ ./work/rustc-1.73.0-src/library/std/src/sys/unix/time.rs
> 2023-12-28 17:40:34.908068763 +0000
> @@ -74,6 +74,8 @@
>      }
>
>      const fn new(tv_sec: i64, tv_nsec: i64) -> Timespec {
> +       #[cfg(target_os = "netbsd")]
> +        let tv_nsec = if tv_nsec < 0 { 0 } else { tv_nsec };
>          assert!(tv_nsec >= 0 && tv_nsec < NSEC_PER_SEC as i64);
>          // SAFETY: The assert above checks tv_nsec is within the valid range
>          Timespec { tv_sec, tv_nsec: unsafe { Nanoseconds(tv_nsec as u32) } }
>
> did the job indeed (apparently rust is not happy with parentheses
> around the if-condition, though...;)
>
> $ /root/nu.old -c "cd /; ls -l "
> thread 'main' panicked at library/std/src/sys/unix/time.rs:77:9:
> assertion failed: tv_nsec >= 0 && tv_nsec < NSEC_PER_SEC as i64
> note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
> $ /usr/pkg/bin/nu -c "cd /; ls -l"
> ╭────┬─────────────┬──────┬────────┬──────────┬───────────┬───────────┬──────────┬──────┬───────┬──────────┬──────────────┬────────────────┬───────────────╮
> │  # │    name     │ type │ target │ readonly │   mode    │ num_links
> │  inode   │ user │ group │   size   │   created    │    accessed    │
>   modified    │
> ├────┼─────────────┼──────┼────────┼──────────┼───────────┼───────────┼──────────┼──────┼───────┼──────────┼──────────────┼────────────────┼───────────────┤
> │  0 │ altroot     │ dir  │        │ false    │ rwxr-xr-x │         2
> │  1915520 │ root │ wheel │    512 B │ a year ago   │ 17 hours ago   │
> 8 months ago  │
> │  1 │ bin         │ dir  │        │ false    │ rwxr-xr-x │         2
> │  8269440 │ root │ wheel │  1,024 B │ a year ago   │ 10 hours ago   │
> 2 days ago    │
> ...
>
> Chavdar
> (I'll try next the patch kernfs_vnops.c; I guess it might be more generic)

This patch also works:
...
$ /root/nu.old -c "cd /kern; ls -l "
╭────┬───────────┬──────────────┬────────┬──────────┬───────────┬───────────┬───────┬──────┬───────┬──────────┬───────────────┬───────────────┬───────────────╮
│  # │   name    │     type     │ target │ readonly │   mode    │
num_links │ inode │ user │ group │   size   │    created    │
accessed    │   modified    │
├────┼───────────┼──────────────┼────────┼──────────┼───────────┼───────────┼───────┼──────┼───────┼──────────┼───────────────┼───────────────┼───────────────┤
│  0 │ boottime  │ file         │        │ true     │ r--r--r-- │
   1 │     4 │ root │ wheel │     11 B │ 2 minutes ago │ 2 minutes ago
│ 2 minutes ago │
│  1 │ copyright │ file         │        │ true     │ r--r--r-- │
   1 │     5 │ root │ wheel │    358 B │ now           │ now
│ now           │
│  2 │ hostname  │ file         │        │ false    │ rw-r--r-- │
   1 │     6 │ root │ wheel │     16 B │ now           │ now
│ now           │

....

using the same kernel as before with the sole difference as above.

Of course, the problem existed only if /kern was mounted.

I guess this patch should be committed also to the currently supported
versions.



>
> >
> > -RVP
> >
>
>
> --
> ----



-- 
----


Home | Main Index | Thread Index | Old Index