Git Product home page Git Product logo

Comments (8)

TeeJaey avatar TeeJaey commented on June 11, 2024

I would like to comment that I am also running into this issue.

I so far always swapped 0xdeadbeaf for 0xdeadbea0 since that is a multiple of 0x4.

While that works, I am worried I might run into bigger problems later down the line.

from blog_os.

carloalbertogiordano avatar carloalbertogiordano commented on June 11, 2024

Hi, maybe the read_unaligned and the write_unaligned could be used in this case. I have not encountered this error so far.
Here are some links:
https://doc.rust-lang.org/std/ptr/fn.read_unaligned.html
https://doc.rust-lang.org/std/ptr/fn.write_unaligned.html

from blog_os.

PitchBlackNights avatar PitchBlackNights commented on June 11, 2024

@carloalbertogiordano
Thanks, but those can't be used as the os doesn't contain, or support, the std crate

from blog_os.

bjorn3 avatar bjorn3 commented on June 11, 2024

These functions are re-exports from libcore, which is supported. So you can write core::ptr::read_unaligned and core::ptr::write_unaligned.

from blog_os.

PitchBlackNights avatar PitchBlackNights commented on June 11, 2024

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

from blog_os.

cubed-guy avatar cubed-guy commented on June 11, 2024

@bjorn3 Can confirm. core::ptr::write_unaligned does work.
But, any idea as to why the standard syntax doesn't work anymore?

from blog_os.

bjorn3 avatar bjorn3 commented on June 11, 2024

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.

from blog_os.

PitchBlackNights avatar PitchBlackNights commented on June 11, 2024

Okay, so that's just how rustc compiles it now. Thanks!

from blog_os.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.