| Why is the x86 undefined instruction called ud2? Why 2?(devblogs.microsoft.com) | |
| 254 points by ibobev 1 day ago | 58 comments | |
tl;dr: The x86 `ud2` instruction is guaranteed to raise an invalid opcode exception, often emitted by compilers after `[[noreturn]]` calls. It's named "ud2" because two earlier undocumented byte sequences (`0F FF` and `0F B9`) were informally used for the same purpose, and Intel retroactively named them `ud0` and `ud1` after Hyrum's Law forced them to preserve the behavior. `ud2` is preferred because it's a clean two-byte instruction with no operands, avoiding edge cases where operand decoding crosses into a non-present page and raises an access violation instead. | |
HN Discussion:
| |