frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Google is dead. Where do we go now?

https://www.circusscientist.com/2025/12/29/google-is-dead-where-do-we-go-now/
157•tomjuggler•1h ago•118 comments

All Delisted Steam Games

https://delistedgames.com/all-delisted-steam-games/
95•Bondi_Blue•2h ago•23 comments

Static Allocation with Zig

https://nickmonad.blog/2025/static-allocation-with-zig-kv/
132•todsacerdoti•5h ago•67 comments

Flame Graphs vs. Tree Maps vs. Sunburst (2017)

https://www.brendangregg.com/blog/2017-02-06/flamegraphs-vs-treemaps-vs-sunburst.html
55•gudzpoz•2d ago•8 comments

List of domains censored by German ISPs

https://cuiiliste.de/domains
182•elcapitan•3h ago•71 comments

The production bug that made me care about undefined behavior

https://gaultier.github.io/blog/the_production_bug_that_made_me_care_about_undefined_behavior.html
58•birdculture•3h ago•34 comments

Which Humans?

https://osf.io/preprints/psyarxiv/5b26t_v1
15•surprisetalk•1h ago•3 comments

Left Behind: Futurist Fetishists, Prepping and the Abandonment of Earth

https://www.boundary2.org/2019/08/sarah-t-roberts-and-mel-hogan-left-behind-futurist-fetishists-p...
9•naves•2h ago•3 comments

The Future of Software Development Is Software Developers

https://codemanship.wordpress.com/2025/11/25/the-future-of-software-development-is-software-devel...
36•cdrnsf•2h ago•10 comments

Show HN: Aroma: Every TCP Proxy Is Detectable with RTT Fingerprinting

https://github.com/Sakura-sx/Aroma
33•Sakura-sx•4d ago•17 comments

High-performance C++ hash table using grouped SIMD metadata scanning

https://github.com/Cranot/grouped-simd-hashtable
23•rurban•5d ago•8 comments

GOG is getting acquired by its original co-founder

https://www.gog.com/blog/gog-is-getting-acquired-by-its-original-co-founder-what-it-means-for-you/
433•haunter•4h ago•245 comments

Show HN: Superset – Terminal to run 10 parallel coding agents

https://superset.sh/
46•avipeltz•6d ago•34 comments

Libgodc: Write Go Programs for Sega Dreamcast

https://github.com/drpaneas/libgodc
170•drpaneas•7h ago•39 comments

Show HN: Evidex – AI Clinical Search (RAG over PubMed/OpenAlex and SOAP Notes)

https://www.getevidex.com
21•amber_raza•4h ago•4 comments

Static Allocation for Compilers

https://matklad.github.io/2025/12/23/static-allocation-compilers.html
11•enz•5d ago•3 comments

Nvidia takes $5B stake in Intel under September agreement

https://www.reuters.com/legal/transactional/nvidia-takes-5-billion-stake-intel-under-september-ag...
146•taubek•4h ago•50 comments

Kidnapped by Deutsche Bahn

https://www.theocharis.dev/blog/kidnapped-by-deutsche-bahn/
831•JeremyTheo•9h ago•776 comments

Linux DAW: Help Linux musicians to quickly and easily find the tools they need

https://linuxdaw.org/
141•prmoustache•9h ago•72 comments

Meta's ads tools started switching out top-performing ads with AI-generated ones

https://www.businessinsider.com/meta-ai-generating-bizarre-ads-advantage-plus-2025-10
84•zdw•1h ago•51 comments

You can't design software you don't work on

https://www.seangoedecke.com/you-cant-design-software-you-dont-work-on/
199•saikatsg•13h ago•68 comments

Show HN: Z80-μLM, a 'Conversational AI' That Fits in 40KB

https://github.com/HarryR/z80ai
450•quesomaster9000•15h ago•101 comments

Why is calling my asm function from Rust slower than calling it from C?

https://ohadravid.github.io/posts/2025-12-rav1d-faster-asm/
81•gavide•2d ago•26 comments

Binance's Trust Wallet extension hacked; users lose $7M

https://www.web3isgoinggreat.com/?id=trust-wallet-hack
31•ilamont•1h ago•2 comments

Karpathy on Programming: "I've never felt this much behind"

https://twitter.com/karpathy/status/2004607146781278521
172•rishabhaiover•3d ago•115 comments

What an unprocessed photo looks like

https://maurycyz.com/misc/raw_photo/
2255•zdw•23h ago•364 comments

Feynman's Hughes Lectures: 950 pages of notes

https://thehugheslectures.info/the-lectures/
151•gnubison•10h ago•34 comments

Show HN: See what readers who loved your favorite book/author also loved to read

https://shepherd.com/bboy/2025
102•bwb•9h ago•24 comments

Show HN: Per-instance TSP Solver with No Pre-training (1.66% gap on d1291)

12•jivaprime•7h ago•2 comments

Show HN: Vibe coding a bookshelf with Claude Code

https://balajmarius.com/writings/vibe-coding-a-bookshelf-with-claude-code/
240•balajmarius•8h ago•182 comments
Open in hackernews

The production bug that made me care about undefined behavior

https://gaultier.github.io/blog/the_production_bug_that_made_me_care_about_undefined_behavior.html
57•birdculture•3h ago

Comments

titzer•2h ago
tldr; the UB was reading uninitialized data in a struct. The C++ rules for when default initialization occurs are crazy complex.

I think a sanitizer probably would have caught this, but IMHO this is the language's fault.

Hopefully future versions of C++ will mandate default initialization for all cases that are UB today and we can be free of this class of bug.

trueismywork•2h ago
For now, best strategy is to initialize everything explicitly.
torstenvl•2h ago
Yeah... but I wouldn't characterize the bug itself (in its essential form) as UB.

Even if the implementation specified that the data would be indeterminate depending on what existed in that memory location previously, the bug would still exist.

Even if you hand-coded this in assembly, the bug would still exist.

The essence of the bug is uninitialized data being garbage. That's always gonna be a latent bug, regardless of whether the behavior is defined in an ISO standard.

forrestthewoods•2h ago
Yeah I agree. This is a classic “uninitialized variable has garbage memory value” bug. But it is not a “undefined nasal demons behavior” bug.

That said, we all learn this one! I spent like two weeks debugging a super rare desync bug in a multiplayer game with a P2P lockstep synchronous architecture.

Suffice to say I am now a zealot about providing default values all the time. Thankfully it’s a lot easier since C++11 came out and lets you define default values at the declaration site!

titzer•1h ago
I prefer language constructs define that new storage is zero-initialized. It doesn't prevent all bugs (i.e. application logic bugs) but at least gives deterministic results. These days it's zero cost for local variables and near-zero cost for fields. This is the case in Virgil.
kevin_thibedeau•1h ago
C & C++ run on systems where it may not be zero cost. If you need low latency startup it could be a liability to zero out large chunks of memory.
ablob•24m ago
I think it's acceptable to leave an escape hatch for these situations instead of leaving it to easy to misunderstand nooks and crannies of the standard.

You don't want to zero out the memory? Slap a "foo = uninitialized" in there to have that exact behavior and get the here be demons sign for free.

forrestthewoods•9m ago
Yeah this issue is super obvious and non-controversial.

Uninitialized state is totally fine as an opt-in performance optimization. But having a well defined non-garbage default value should obviously be the default.

Did C fuck that up 50 years ago? Yeah probably. They should have known better even then. But that’s ok. It’s a historical artifact. All languages are full of them. We learn and improve!

andrewaylett•56m ago
That makes things worse if all-zero is not a valid value for the datatype. I'd much prefer a set-up that requires you to initialise explicitly. Rust, for example, has a `Default` trait that you can implement if there is a sensible default, which may well be all-zero. It also has a `MaybeUninit` holder which doesn't do any initialisation, but needs an `unsafe` to extract the value once you've made sure it's OK. But if you don't have a suitable default, and don't want/need to use `unsafe`, you have to supply all the values.
kayo_20211030•2h ago
Great post. It was both funny and humble. Of course, it probably wasn't at all funny at the time.
vhantz•1h ago
The two fields in the struct are expected to be false unless changed, then initialize them as such. Nothing is gained by leaving it to the compiler, and a lot is lost.
gwd•1h ago
I think the point is that sometimes variables are defined by the language spec as initialized to zero, and sometimes they aren't.

Perhaps what you mean is, "Nothing is to be gained by relying on the language spec to initialize things to zero, and a lot is lost"; I'd agree with that.

vhantz•1h ago
Please don't be pedantic. Compilers implement the standard, otherwise it's just a text document.
nneonneo•1h ago
Even calling uninitialized data “garbage” is misleading. You might expect that the compiler would just leave out some initialization code and compile the remaining code in the expected way, causing the values to be “whatever was in memory previously”. But no - the compiler can (and absolutely will) optimize by assuming the values are whatever would be most convenient for optimization reasons, even if it would be vanishingly unlikely or even impossible.

As an example, consider this code (godbolt: https://godbolt.org/z/TrMrYTKG9):

    struct foo {
        unsigned char a, b;
    };

    foo make(int x) {
        foo result;
        if (x) {
            result.a = 13;
        } else {
            result.b = 37;
        }
        return result;
    }
At high enough optimization levels, the function compiles to “mov eax, 9485; ret”, which sets both a=13 and b=37 without testing the condition at all - as if both branches of the test were executed. This is perfectly reasonable because the lack of initialization means the values could already have been set that way (even if unlikely), so the compiler just goes ahead and sets them that way. It’s faster!
arrowsmith•1h ago
How is this an "optimization" if the compiled result is incorrect? Why would you design a compiler that can produce errors?
tehjoker•1h ago
It's not incorrect. Where is the flaw?
Negitivefrags•1h ago
It’s not incorrect.

The code says that if x is true then a=13 and if it is false than b=37.

This is the case. Its just that a=13 even if x is false. A thing that the code had nothing to say about, and so the compiler is free to do.

foltik•8m ago
Ok, so you’re saying it’s “technically correct?”

Practically speaking, I’d argue that a compiler assuming uninitialized stack or heap memory is always equal to some arbitrary convenient constant is obviously incorrect, actively harmful, and benefits no one.

throwatdem12311•15m ago
Because a could be 13 even if x is false because initialisation of the struct doesn’t have defined behavior of what the initial values of a and b need to be.

Same for b. If x is true, b could be 37 no matter how unlikely that is.

recursivecaveat•1h ago
Even the notion that uninitialized memory contain values is kind of dangerous. Once you access them you can't reason about what's going to happen at all. Behaviour can happen that's not self-consistent with any value at all: https://godbolt.org/z/adsP4sxMT
masklinn•20m ago
Is that an old 'bot? because I noticed it was an old version of Clang, and I tried switching to the latest Clang which is hilarious: https://godbolt.org/z/fra6fWexM
afiori•13m ago
This is gold
quietbritishjim•36m ago
If I understand it right, in principle the compiler doesn't even need to do that.

It can just leave the result totally uninitialised. That's because both code paths have undefined behaviour: whichever of result.x or result.y is not set is still copied at "return result" which is undefined behaviour, so the overall function has undefined behaviour either way.

It could even just replace the function body with abort(), or omit the implementation entirely (even the ret instruction, allowing execution to just fall through to whatever memory happens to follow). Whether any computer does that in practice is another matter.

masklinn•30m ago
> It can just leave the result totally uninitialised. That's because both code paths have undefined behaviour: whichever of result.x or result.y is not set is still copied at "return result" which is undefined behaviour, so the overall function has undefined behaviour either way.

That is incorrect, per the resolution of DR222 (partially initialized structures) at WG14:

> This DR asks the question of whether or not struct assignment is well defined when the source of the assignment is a struct, some of whose members have not been given a value. There was consensus that this should be well defined because of common usage, including the standard-specified structure struct tm.

As long as the caller doesn't read an uninitialised member, it's completely fine.

masklinn•26m ago
Things can get even wonkier if the compiler keeps the values in registers, as two consecutive loads could use different registers based as you say on what's the most convenient for optimisation (register allocation, code density).
jmgao•19m ago
There are some even funnier cases like this one: https://gcc.godbolt.org/z/cbscGf8ss

The compiler sees that foo can only be assigned in one place (that isn't called locally, but could called from other object files linked into the program) and its address never escapes. Since dereferencing a null pointer is UB, it can legally assume that `*foo` is always 42 and optimizes out the variable entirely.

publicdebates•7m ago
To those who are just as confused as me:

Compilers can do whatever they want when they see UB, and accessing an unassigned and unassiganble (file-local) variable is UB, therefore the compiler can just decide that *foo is in fact always 42, or never 42, or sometimes 42, and all would be just as valid options for the compiler.

(I know I'm just restating the parent comment, but I had to think it through several times before understanding it myself, even after reading that.)

mac3n•1h ago
Many years had a customer complaint about undefined data changing value in Fortran 77. It turned out that the compiler never allocated storage for uninitialized variables, so it was aliased to something else.

Compiler was changed to allocate storage for any referenced varibles.

panstromek•1h ago
I have bumped into this myself, too. It's really annoying. The biggest footgun isn't even discussed explicitly and it might be how the error got introduced - it's when the struct goes from POD to non-POD or vice-versa, the rules change, so completely innocent change, like adding a string field, can suddenly create undefined behaviour in unrelated code that was correct previously.
inglor_cz•1h ago
Symbian's way of avoiding this was to use a class called CBase to derive from. CBase would memset the entire allocated memory for the object to binary zeros, thus zeroizing any member variable.

And by convention, all classes derived from CBase would start their name with C, so something like CHash or CRectangle.

MutableLambda•1h ago
Yeah, looks pretty straightforward to me, but I used to write C++ for a living. I mean, there are complicated cases in C++ starting with C++11, this one is not really one of them. Just init the fields to false. Most of these cases is just C++ trying to bring in new features without breaking legacy code, it has become pretty difficult to keep up with it all.
fizzynut•55m ago
Even if you fixed the initialized data problem, this code is still a bug waiting to happen. It should be a single bool in the struct to handle the state for the function as there are only two states that actually make sense.

succeeded = true; error = true; //This makes no sense

succeeded = false; error = false; //This makes no sense

Otherwise if I'm checking a response, I am generally going to check just "succeeded" or "error" and miss one of the two above states that "shouldn't happen", or if I check both it's both a lot of awkward extra code and I'm left with trying to output an error for a state that again makes no sense.

deepsun•45m ago
It happens often when "error" field is not a bool, but a string, aka error_message. Could be empty string, or _null_, or even _undefined_ if we're in JS.

Then the obvious question why do we need _succeeded_ at all, if we can always check for _error_. Sometimes it can be useful, when the server doesn't know itself if the operation is succeeded (e.g. an IO/database operation timed out), so it might be succeeded, but should also show an error message to user.

Another possibility if the succeeded is not a bool, but, say, "succeeded_at" timestamp. In general, I noticed that almost always any boolean value in database can be replaced with a timestamp or an error code.