Skip to content

Commit

Permalink
fix(x86_64): use unaligned write for TLS pointer
Browse files Browse the repository at this point in the history
TLS alignment may be 4 and require an unaligned write.
This was found with hermit-c and cargo-careful.
  • Loading branch information
mkroening committed Nov 20, 2024
1 parent dca9fe1 commit 55f3e4a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/arch/x86_64/kernel/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl TaskTLS {
// thread_ptr = block_ptr + tls_offset
let thread_ptr = block[tls_offset..].as_mut_ptr().cast::<()>();
unsafe {
thread_ptr.cast::<*mut ()>().write(thread_ptr);
thread_ptr.cast::<*mut ()>().write_unaligned(thread_ptr);
}

let this = Self {
Expand Down

0 comments on commit 55f3e4a

Please sign in to comment.