Skip to content
Discussion options

You must be logged in to vote

Hi @studioframes!

Both @AntonAzer and @willsun0 nailed the root cause, but there is an additional subtle layer regarding how the instruction pointer (RIP) behaves during cross-cache-line fetches that explains why you get an actual SIGSEGV instead of just a bad value inside RAX.

The "Mystery" Segfault Explained

Looking closely at your assembly snippet:

.loop:movrax,0x1122334455667788patch_target equ \$ -8add qword [rel patch_target],1

If the 8-byte immediate value (0x1122334455667788) crosses a 64-byte cache line boundary, the write is non-atomic. Under high CPU load and multi-core context switching, the Instruction Fetch Unit (IFU) can read a partially written, corrupted…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@studioframes
Comment options

Answer selected bystudioframes
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QuestionAsk and answer questions about GitHub features and usageProgramming HelpDiscussions around programming languages, open source and software developmentsource:uiDiscussions created via Community GitHub templates
4 participants
@studioframes@CristianOlivera1@willsun0@AntonAzer