Hacker News new | ask | show | jobs
by Neywiny 20 days ago
Interesting they show clangd crashing in vscode. That's been my biggest gripe with it. But they also show clice crashing in the same spot? Seems odd to not just fix it
3 comments

They explain exactly why in article:

Because C++ is simply too complex, and on certain corner cases the compiler can easily crash or leak memory. That is especially true for incomplete code in the middle of editing: a huge downstream user base tests compilers on complete code, while very few people test them on half-written code, where the compiler mostly falls back on best-effort heuristics

It's the compiler that crashes. Both clangd and clice are built on top of the same compiler (clang) which is why both experience a crash on the same code.

I'm not a C++ expert, but I don't see anything in the shown snippet that would cause a language server crash, so I imagine the server is crashing on something off screen.

I could understand them showing off crash recovery by using code deliberately written to crash the language server, and so not being something you can "fix".

IME it's nothing about the code. It'll be weird setup issues that aren't traceable. In one IDE I end up having to just have a new workspace and copy the code over and somehow that fixes it. It's truly beyond me. At best I'll see an ENOENT error but that doesn't help me much.
The problem is that the language is simply too complex with way too many corner cases.

For instance, C++ the only programming language that comes to my mind where the grammar is type 0 in the Chomsky classification - it means it has to be parsed with a Turing machine and thus every C++ compiler suffers from the halting problem.

This means that having a C++ compiler that will never crash or hang is literally mathematically impossible unless you stick to only parsing a subset of the grammar. Modern compilers bypass this by doing things like capping how many times templates can recurse, etc but this means that the frontend it will inevitably end up in unsavoury corners where it relies on its authors explicitly handling them - which sometimes they did not

> The problem is that the language is simply too complex with way too many corner cases.

Bullshit. These are compiler bugs that can be fixed. It's just not a priority because it doesn't affect normal use with valid code.

> This means that having a C++ compiler that will never crash or hang is literally mathematically impossible unless you stick to only parsing a subset of the grammar.

This is only a theoretical concern since every compiler will accept arbitrarily large programs anyway due to being built on fixed-width integer architectures which can only address finite amounts of memory. Real compiler can set reasonable limits where they can avoid both hangs and crashes.