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

could not compile ntapi (lib) due to 2 previous errors. error[E0793]: reference to packed field is unaligned #120

Open
CrackAnna opened this issue Jan 13, 2024 · 1 comment

Comments

@CrackAnna
Copy link

error[E0793]: reference to packed field is unaligned
--> C:\Users\liuyu.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\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)

error[E0793]: reference to packed field is unaligned
--> C:\Users\liuyu.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\ntapi-0.3.7\src\ntexapi.rs:2807:25
|
2807 | ((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)

@jorge-ortega
Copy link

Running cargo tree --workspace --target all --invert ntapi points to the path_tracer example pulling in ntapi (see output below).

ntapi v0.3.7
├── mio v0.7.14
│   ├── mio-misc v1.2.2
│   │   └── winit v0.25.0
│   │       ├── glutin v0.27.0
│   │       │   ├── glium v0.30.2
│   │       │   │   ├── imgui-glium-renderer v0.8.2
│   │       │   │   │   └── path_tracer v0.1.0 (C:\Users\jorge\Workspace\rust-cuda\examples\cuda\cpu\path_tracer)
│   │       │   │   └── path_tracer v0.1.0 (C:\Users\jorge\Workspace\rust-cuda\examples\cuda\cpu\path_tracer)
│   │       │   └── path_tracer v0.1.0 (C:\Users\jorge\Workspace\rust-cuda\examples\cuda\cpu\path_tracer)
│   │       └── imgui-winit-support v0.8.2
│   │           └── path_tracer v0.1.0 (C:\Users\jorge\Workspace\rust-cuda\examples\cuda\cpu\path_tracer)
│   └── winit v0.25.0 (*)
└── sysinfo v0.20.5
    └── path_tracer v0.1.0 (C:\Users\jorge\Workspace\rust-cuda\examples\cuda\cpu\path_tracer)

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

2 participants