Re:Sometimes it is a kernel bug: bind() in Linux 6.0.16
by valleyer on Friday January 13, 2023 @05:46PM
(#34374967)
Assuming int is 32 bits wide, `1 << 32` invokes UB.
[ Parent
| on HN ]
Re:Sometimes it is a kernel bug: bind() in Linux 6.0.16
by astrange on Friday January 13, 2023 @05:57PM
(#34375068)
Indeed it does.
(Spoiler: it prints uninitialized stack memory. A bit closer to demons flying out your nose than you'd expect!)
Re:Sometimes it is a kernel bug: bind() in Linux 6.0.16
by valleyer on Saturday January 14, 2023 @05:01PM
(#34384574)
Fun. Basically, it decides that (due to UB) it can simply not materialize the argument and carry on.
On Darwin/x86_64, this actually means that it prints out bits from an "uninitialized" register, specifically %rsi in this case, since that's where the second argument should be (even for variadic functions).
Certainly a jarring failure mode! However, if updating your compiler causes you to run into this, you already have a bug in your code (one that clang -- arguably not forcefully enough -- already warns you of).