-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Misaligned Pointer panic in the Paging Introduction post #1215
Comments
I would like to comment that I am also running into this issue. I so far always swapped While that works, I am worried I might run into bigger problems later down the line. |
Hi, maybe the read_unaligned and the write_unaligned could be used in this case. I have not encountered this error so far. |
@carloalbertogiordano |
These functions are re-exports from libcore, which is supported. So you can write |
Okay, thanks @bjorn3 ! I haven't tried it, but I think it will work. I'll leave this open for now though, as it should be working without read/write_unaligned |
@bjorn3 Can confirm. |
Dereferencing unaligned pointers is UB. Previously if you were lucky the compiler wouldn't miscompile it, but to catch this UB, rustc recently added a compiler pass when debug assertions are enabled which adds code to check on every pointer dereference if the pointer is aligned or not and if not aborts. This helps finding this UB. |
Okay, so that's just how rustc compiles it now. Thanks! |
I don't know if this is very important, but it's been driving me crazy trying to fix it.
I'm almost at the end of the Introduction to Paging. I'm at the test to see if reading and writing to the code segment address will cause a paging fault.
When I run the binary, it spits out:
Here is the code in question (I'm guessing that it's really complaining about line 16, which is the first line included in this snippet):
I've gotten this error on previous uses of
0xdeadbeaf
as a virtual address, so I would always just swap those out for unnecessarily large addresses like0x4444444444
.I did look to see if anyone else was having this error, and I did find one person.
The text was updated successfully, but these errors were encountered: