-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Why does Zig choose to use 0xAA
as the undefined marker byte instead of 0xCC
?
#15603
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
Comments
0xAA
as the undefined padding byte instead of 0xCC
?0xAA
as the undefined marker byte instead of 0xCC
?
|
Stack filling
No. |
P.S.: |
I do agree that it's more of niche. Incremental compilation and/or dynamic (re)loading via linker utilizes it.
That sounds more convincing to me. Additionally, the alternate of |
I was considering opening a bikeshed issue about The reason I was going to do so, is that I recently spotted a valid My proposal is The argument for Do I think it's important to change the value we're using? No, I don't. I do think On the other hand, it doesn't literally scream at you like AAAAAAAAAAA does. That might be sufficient reason to keep the current choice. |
I like 0xaa |
I had a question when I came across #15585:
Why does Zig choose to use
0xAA
as the undefined marker byte instead of0xCC
?As far as I know, Microsoft’s C compiler emits
0xCC
as marker byte in Debug mode [1].They originally chose
0xCC
because it decompiles into the x86 instruction “int3
”, so the debugger will interrupt in case the CPU tries to execute the padding bytes (back when DEP wasn’t a thing yet).However, although the modern CPUs protects against executing data sections,
0xCC
has already become a sub-culture and many programmers are already able to spot it during a debugging session:(Actually it’s −858993460, but you can’t search negative numbers on Google.)
“手持两把锟斤拷, 口中疾呼烫烫烫。” (“Holding two metal pieces of � [11], I shouted: Hot! Hot! Hot!”)
That is to say,
0xCC
is a well-known value with a long history and a sub-culture. When a novice developer learns to code and sees this, searching this value (either in numeric form or text form at any encoding other than UTF-8) will lead them to the solution.However, using
0xAA
won’t lead these young programmers into anything: I searched “1431655766”, “2863311530”, “6148914691236517206”, and “12297829382473034410”. Only the third number led me to a couple of web pages owned by LLVM [12] or GCC [13], none of them explains anything related to uninitialized variables.TL;DR: I want to propose we modify
0xAA
into0xCC
.Image: Screenshot of a C++ debugger. [Image source]
The text was updated successfully, but these errors were encountered: