+
Skip to content

df: Fix overflow error on WSL. Default to 0 when the values are non-sense. #5381

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

Merged
merged 2 commits into from
Oct 10, 2023

Conversation

howard0su
Copy link
Contributor

@howard0su howard0su commented Oct 9, 2023

Hit crash like this:

thread 'main' panicked at src/uu/df/src/table.rs:156:21:
attempt to subtract with overflow
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
   1: core::panicking::panic_fmt
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:117:5
   3: <uu_df::table::Row as core::convert::From<uu_df::filesystem::Filesystem>>::from
             at ./src/uu/df/src/table.rs:156:21
   4: uu_df::table::Table::new
             at ./src/uu/df/src/table.rs:392:27
   5: uu_df::uumain::uumain
             at ./src/uu/df/src/df.rs:470:20
   6: uu_df::uumain
             at ./src/uu/df/src/df.rs:430:1
   7: coreutils::main
             at ./src/bin/coreutils.rs:103:31
   8: core::ops::function::FnOnce::call_once
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

After the fix, manual validated the df output with native df on WSL Debian. It works as expected. Native df also default to 0.

@sylvestre
Copy link
Contributor

cool, thanks
how did you get this error ?

could you please add a test to make sure we don't regress in the future?

@howard0su
Copy link
Contributor Author

Sure. I will add one more test case.

Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! I wonder why these values are weird on Windows 🤔 Good workaround nonetheless. Would you mind also putting in a comment describing the issue in the code?

@howard0su
Copy link
Contributor Author

update per the suggestions. add a test case as well.

@shinhs0506
Copy link
Contributor

i filed this issue to the wsl team a while ago, but the issue is caused by the filesystem reporting negative numbers. related t o #3640

@sylvestre sylvestre merged commit f3f82c1 into uutils:main Oct 10, 2023
@howard0su howard0su deleted the df_wsl branch October 13, 2023 11:41
@sylvestre sylvestre changed the title Fix overflow error on WSL. Default to 0 when the values are non-sense. df: Fix overflow error on WSL. Default to 0 when the values are non-sense. Oct 15, 2023
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 this pull request may close these issues.

4 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载