ClementTsang / bottom

Yet another cross-platform graphical process/system monitor.
https://clementtsang.github.io/bottom
MIT License
10k stars 237 forks source link

[Bug] cargo install error :reference to packed field is unaligned #1056

Closed lost22git closed 1 year ago

lost22git commented 1 year ago

Checklist

Describe the issue

cargo install error msg

error[E0793]: reference to packed field is unaligned
*tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
     |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
     = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error: could not compile `ntapi` due to 2 previous errors

What operating system and version are you using?

win11

What architecture are you using?

x86_64 / AMD64

What terminal(s) are you running bottom on?

windows terminal

What version of bottom are you running?

latest

How did you install bottom?

cargo

How can we reproduce this?

cargo install bottom

Additional information

No response

ClementTsang commented 1 year ago

Hmmm, interesting. What version of Rust are you using? I'm guessing it might be due to some warning that's been upgraded to an error in recent versions of Rust.

EDIT: Yeah, I think it's this. If I build on 1.67:

warning: the following packages contain code that will be rejected by a future version of Rust: ntapi v0.3.7
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`

Relevant upstream issue: https://github.com/MSxDOS/ntapi/issues/15

ClementTsang commented 1 year ago

I guess for now a workaround is using the pre-built binaries? There's a winget package and MSI installer.

ClementTsang commented 1 year ago

Ah. Are you using nightly or beta? I can run cargo install bottom fine on stable (1.68), though I definitely do need to fix this/find workarounds for the future.

lost22git commented 1 year ago

@ClementTsang it works after switching to stable channel, thanks ;-)

ClementTsang commented 1 year ago

Glad it worked out for you!


Just as an extra update (mostly for myself), this is already fixed in the current master branch, as we only rely on ntapi 0.4.0, which reports no issues when I try checking with beta/nightly (cargo +beta check). Trying this with 0.8.0, which uses 0.3.7, causes the errors above.

I'll likely do a 0.8.1/0.9.0 update within the next few weeks, maybe after #812.

SHarksGANG commented 1 year ago

Hi ! I am installing (cargo install sugar-cli), the installation ends with an error. Help solve the problem! I've been crying for days!

error[E0793]: reference to packed field is unaligned --> C:\Users\iVwVi.cargo\registry\src\github.com-1ecc6299db9ec823\ntapi-0.3.7\src\ntexapi.rs:2783:52 2783 tick_count.QuadPart_mut() = read_volatile(&(USER_SHARED_DATA).u.TickCountQuad); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
 = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
error[E0793]: reference to packed field is unaligned --> C:\Users\iVwVi.cargo\registry\src\github.com-1ecc6299db9ec823\ntapi-0.3.7\src\ntexapi.rs:2807:25 2807 ((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
 = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)

Compiling socket2 v0.4.9 Compiling form_urlencoded v1.1.0 For more information about this error, try rustc --explain E0793. error: could not compile ntapi due to 2 previous errors warning: build failed, waiting for other jobs to finish... error: failed to compile spl-token-cli v2.4.0, intermediate artifacts can be found at C:\Users\iVwVi\AppData\Local\Temp\cargo-installoBFPUO

C:\Windows\System32>

ClementTsang commented 1 year ago

@SHarkGANGS I think you need to bring this up in the appropriate repo, that's an issue the maintainer will need to handle. I don't know what sugar-cli is.

SHarksGANG commented 1 year ago

I made a mistake, here is the command that ends with an error - spl-token-cli

ClementTsang commented 1 year ago

Yeah, definitely bring that up in the appropriate repo, as it doesn't seem to relate to bottom here. As a workaround though, you can probably install using an older version of Rust.

SHarksGANG commented 1 year ago

Yeah, definitely bring that up in the appropriate repo, as it doesn't seem to relate to bottom here. As a workaround though, you can probably install using an older version of Rust.

Can you suggest a windows installer startup command ? I run (rustup-init.exe) the installer file as an administrator, select the number 1 Where is the repository where you can discuss this problem, I do not understand !

ClementTsang commented 1 year ago

You are installing another program that is not bottom, from the looks of it. This repo is for the program bottom. So if the issue is not about bottom, I cannot help you much.

ClementTsang commented 1 year ago

This is the sugar-cli repo: https://github.com/metaplex-foundation/sugar

Please use that instead.

SHarksGANG commented 1 year ago

This is the sugar-cli repo: https://github.com/metaplex-foundation/sugar

Please use that instead.

### Honor and respect !