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

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

Closed
1 task done
lost22git opened this issue Mar 11, 2023 · 13 comments
Closed
1 task done

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

lost22git opened this issue Mar 11, 2023 · 13 comments
Labels
bug Something isn't working the way that is expected.

Comments

@lost22git
Copy link

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

@lost22git lost22git added the bug Something isn't working the way that is expected. label Mar 11, 2023
@ClementTsang
Copy link
Owner

ClementTsang commented Mar 11, 2023

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: MSxDOS/ntapi#15

@ClementTsang
Copy link
Owner

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

@ClementTsang
Copy link
Owner

ClementTsang commented Mar 11, 2023

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
Copy link
Author

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

@ClementTsang
Copy link
Owner

ClementTsang commented Mar 11, 2023

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

This comment was marked as off-topic.

@ClementTsang

This comment was marked as off-topic.

@SHarksGANG

This comment was marked as off-topic.

@ClementTsang

This comment was marked as off-topic.

@SHarksGANG

This comment was marked as off-topic.

@ClementTsang

This comment was marked as off-topic.

@ClementTsang

This comment was marked as off-topic.

@SHarksGANG

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working the way that is expected.
Projects
None yet
Development

No branches or pull requests

3 participants