kawamuray / linux-taskstats-rs

Rust interface for Linux taskstats
MIT License
9 stars 7 forks source link

taskstats crashes on Linux kernels v5.19 and newer #12

Closed jac-cbi closed 3 days ago

jac-cbi commented 3 months ago

While attempting to run zenith on my Gentoo x86_64 box, I get an immediate crash:

thread '<unnamed>' panicked at 'range end index 432 out of range for slice of length 416', $HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/linux-taskstats-0.5.0/src/model.rs:127:39

The change 662ce1dc9caf4 in the Linux kernel extended struct taskstats by 16 bytes.

@@ -194,6 +194,10 @@ struct taskstats {
        __u64   ac_exe_dev;     /* program binary device ID */
        __u64   ac_exe_inode;   /* program binary inode number */
        /* v12 end */
+
+       /* v13: Delay waiting for write-protect copy */
+       __u64    wpcopy_count;
+       __u64    wpcopy_delay_total;
 };

This change landed in Linux kernel v5.19. So all kernels newer than that should break in the same way.

Looking at the comment in the src/lib.rs, it might be a good idea to revisit the decision to open code the rust struct vice letting bindgen do it. Maybe setting an MSRV would work here?

kawamuray commented 3 months ago

Thanks for reporting.

it might be a good idea to revisit the decision to open code the rust struct vice letting bindgen do it.

Agree. I have to admit that the actual definition of taskstats struct in kernel is evolving much aggressively than I initially expected.

Maybe for backward compatibility we can keep the current definition of taskstats struct in src/lib.rs w/ enabling it w/ a feature flag.

thinkgos commented 2 months ago

me too, but build with statically linked. install use cargo install --git https://github.com/bvaisvil/zenith.git --target x86_64-unknown-linux-musl

thread '<unnamed>' panicked at 'range end index 352 out of range for slice of length 328', /home/thinkgo/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/linux-taskstats-0.5.0/src/model.rs:127:39

my os system call uname -a show follow:

Linux localhost.localdomain 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17 15:42:21 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
kawamuray commented 3 days ago

should be fixed by #13