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

Panic under FreeBSD 12 - attempt to subtract with overflow #60

Open
AlexanderThaller opened this issue May 22, 2019 · 5 comments
Open

Comments

@AlexanderThaller
Copy link
Contributor

AlexanderThaller commented May 22, 2019

Using master at commit 59929b2d7f5d4e520e6dec03499d71c2460fd866 and using FreeBSD 12.0-RELEASE-p3 FreeBSD 12.0-RELEASE-p3 GENERIC amd64 with rustc 1.36.0-nightly (d35181ad8 2019-05-20)

I get the following error when running cargo test:

# cargo test   
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running target/debug/deps/systemstat-29c6b1a37a7b0b74

running 10 tests
test platform::tests::test_battery_life ... ok
test platform::tests::test_cpu_measurement_is_send ... ok
test platform::tests::test_memory ... ok
test platform::tests::test_load_average ... ok
test platform::tests::test_mount_at ... FAILED
test platform::tests::test_networks ... ok
test platform::tests::test_on_ac_power ... FAILED
test platform::tests::test_mounts ... FAILED
test platform::tests::test_cpu_load ... ok
test platform::tests::test_cpu_load_aggregate ... ok

failures:

---- platform::tests::test_mount_at stdout ----
thread 'platform::tests::test_mount_at' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: StringError("statfs() failed") }', src/libcore/result.rs:999:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

---- platform::tests::test_on_ac_power stdout ----
thread 'platform::tests::test_on_ac_power' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: StringError("sysctl() failed") }', src/libcore/result.rs:999:5

---- platform::tests::test_mounts stdout ----
thread 'platform::tests::test_mounts' panicked at 'attempt to subtract with overflow', src/platform/freebsd.rs:220:20


failures:
    platform::tests::test_mount_at
    platform::tests::test_mounts
    platform::tests::test_on_ac_power

test result: FAILED. 7 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '--lib'

(I encountered this problem when I tried to run https://github.com/rabite0/hunter).

@AlexanderThaller
Copy link
Contributor Author

When I add the following debug statements before 220:

impl statfs {
    fn to_fs(&self) -> Filesystem {
        + dbg!(self.f_files as usize);
        + dbg!(self.f_ffree as usize);
        + dbg!(self.f_files as usize - self.f_ffree as usize);

        Filesystem {
            files: self.f_files as usize - self.f_ffree as usize,
            files_total: self.f_files as usize,
            files_avail: self.f_ffree as usize,

I get the following output:

---- platform::tests::test_mounts stdout ----
[src/platform/freebsd.rs:219] self.f_files as usize = 18697390713
[src/platform/freebsd.rs:220] self.f_ffree as usize = 18696449401
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 941312
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 0
[src/platform/freebsd.rs:220] self.f_ffree as usize = 0
[src/platform/freebsd.rs:221] self.f_files as usize - self.f_ffree as usize = 0
[src/platform/freebsd.rs:219] self.f_files as usize = 255
[src/platform/freebsd.rs:220] self.f_ffree as usize = 8421070353367364507
thread 'platform::tests::test_mounts' panicked at 'attempt to subtract with overflow', src/platform/freebsd.rs:221:14

@AlexanderThaller
Copy link
Contributor Author

I'm running zfs with a fairly large pool so maybe thats an issue:

# zpool list
NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
zroot  36.2T  17.1T  19.1T        -         -     1%    47%  1.00x  ONLINE  -

@AlexanderThaller AlexanderThaller changed the title Panic under FreeBsd 12 - attempt to subtract with overflow Panic under FreeBSD 12 - attempt to subtract with overflow May 22, 2019
@AlexanderThaller
Copy link
Contributor Author

I also tried compiling with rust stable rustc 1.34.2 (6c2484dc3 2019-05-13) but same error.

@valpackett
Copy link
Owner

hmm which FS is that? could you also dbg print other info, like name/mountpoint?

@malinoskj2
Copy link

I just ran into this issue myself. I've got a working patch.

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

No branches or pull requests

3 participants