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

error[E0793]: reference to packed field is unaligned -during anchor download #2567

Closed
Sam-Berman1 opened this issue Jul 14, 2023 · 3 comments
Labels

Comments

@Sam-Berman1
Copy link

Sam-Berman1 commented Jul 14, 2023

cargo install --git https://github.com/coral-xyz/anchor avm --locked --force

Sometimes may return:

.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2783:52
     |
2783 |         *tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
     |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
     = note: 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)

Changing the .cargo/git/checkouts/anchor/xxxxxxx/avm/Cargo.toml
To include:

tokio = { version = "1.28.0", features = ["full"] }

&

.cargo/git/anchor/xxxxxx/cli/Cargo.toml

from "~1.14.0" to 1.28.0

Fixed this issue.
Thankful for https://stackoverflow.com/questions/76173195/my-rust-project-is-broken-all-of-the-sudden for hinting

@acheroncrypto
Copy link
Collaborator

cargo install --git https://github.com/coral-xyz/anchor avm --force

should pull the latest tokio version(without --locked argument).

avm doesn't have a direct dependency to tokio but it's getting tokio 1.14.1 because solana-client specifies tokio ~1.14.1. Looks like they've just bumped tokio to 1.29.1 and applied ntapi patch but that is not yet released.

@acheroncrypto
Copy link
Collaborator

This problem only seems to happen on Windows, you'll have much better experience if you use WSL for developing on Solana if you are on Windows.

@acheroncrypto
Copy link
Collaborator

This should be fixed in 0.29.0

anchor/Cargo.lock

Lines 5009 to 5010 in fc3905a

name = "tokio"
version = "1.32.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants