Closed
Description
In https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#clobbered-registers there is no protection for rbx being used for an input register.
According to the reference, reserved registers such as rbx may be allocated into the register class "reg".
If the pointer to the cpu maker name gets put into rbx, the following asm is emitted.
push rbx
cpuid ;rbx is replaced with part of the cpu maker name
mov [rbx], ebx ;rbx is not a valid pointer UNDEFINED BEHAVIOR
;...
This bug should be fixed and a warning should be put in to prevent people from making similar mistakes. An example fix would be using explicit input operands and warning against using automatic integer/pointer register assignment when using rbx(64-bit), esi(32-bit) or rbp in asm.
Metadata
Metadata
Assignees
Labels
No labels