Achievement unlocked: rustc segfault
gist.github.com
gist.github.com
Either way, a really fun read. For some reason I enjoy reading debugging stories for bugs that I almost certainly wouldn't be able to solve myself.
IIRC LLVM's IR verification is not enabled in release build. In other words, if you're using rustc with debug version of LLVM the error message should pop up.
EDIT: "...LLVM's IR verification is not enabled in release build..." this is wrong, LLVM doesn't turn off verification based on its build mode. It is up to the user of LLVM, namely rustc in this case, to enable verification. For instance, you can verify IR after each optimization Pass (which is pretty expensive) by configuring `llvm::StandardInstrumentation` properly. Or you can verify the IR before codegen by switching up one of `llvm::TargetMachine`'s options. Clang always enables the latter (verification) by default but disables the former regardless of the optimization level or its build mode.
I don't know how these checks compare to what clang is doing.
If I understand correctly, it's undefined behaviour to do this:
int *ptr = (int*)42;
As, in order to avoid undefined behaviour, ptr should only be assigned a valid address of an int, or the 'address' one past the end of an array of int, or NULL (logical zero).It's possible things are different when the type is void*, I'm not certain.
Is it documented undefined behavior to feed bad IR into LLVM?
For example, LLVM has a pointer type and a void type, but you may not make a pointer-to-void type, see https://llvm.org/docs/LangRef.html#pointer-type . If you do call `Type::getVoidTy(C)->getPointerTo()` then LLVM will hit an assertion only in a build with assertions enabled. Without assertions LLVM may silently execute UB.
Probably not. As the author describes, LLVM has to tool to check for invalid IR, which they used to investigate the issue and generate an explanatory error message.
Also for LLVM IR, there's llvm-reduce and -opt-bisect-limit.
Not sure if they'd have helped here but they're generally useful tools for tracking down similar issues.
Thank you for sharing. There were GCC segfaults that started appearing on my machine a few months ago, and they magically disappeared after a recent update. Those tools are going to be a massive help next time that happens.
https://github.com/rust-lang/rust/issues?q=is%3Aissue+SIGSEG... => 87 + 291
vs https://github.com/ponylang/ponyc/issues?q=is%3Aissue+SIGSEG... => 11 + 50
Now compare that to a safe systems language, e.g. sbcl: https://bugs.launchpad.net/sbcl/+bugs?field.searchtext=SIGSE... => 1 (invalid)
or clisp: https://sourceforge.net/p/clisp/bugs/?q=%7B%22status%22%3A+%... => 15
(Besides: If GitHub's stats are correct, `ponyc` seems to be >60% C and C++?)
The list of issues you linked in an apparent attempt to support this claim are almost all (or maybe even all) compile time crashes not runtime crashes...
The comment I replied to... I quoted the text that made me think it wasn't. Am I misinterpreting it?
In the general case, no, not without having AGI. There are a subset of bugs that computers can verify (i.e. for a compiler, it might be asserted that "any input that causes a crash is a bug"), but the majority of bugs will require a human-like intelligence to read them and reason about them to determine that "yes, this is a bug".
Given you have to involve a human in the loop to actually fix it, it seems like automating a bounty for it is fixing a problem that doesn't really exist.
There's also vanishingly few projects that want to pay for literally any bug. The majority only want to pay for critical bugs or security vulnerabilities, both of which are purely human judgements.
There's a pretty cool article about it: http://archive.adaic.com/projects/atwork/boeing.html
edit: To those stating it was C++ portion of the compiler code at fault. That's not the point. Ada offers greater protection against segfaults than Rust. Not to mention that part of the compiler still being written in C++ and not Rust doesn't bode well.
The Ada compilers I'm familiar with are also written partly or entirely in C or C++.
A segfault in the portion of the compiler written in C++ no less, though triggered by invalid input from the portion of the compiler written in rust (due to a logic bug).
Unless GPs point is that "rust code can still have bugs" (so can ADA) or "the rust compiler still has bugs" (I'm willing to bet so do all ADA compilers) I don't see how this supports his claim.
But agreed that seeing a compiler segfault doesn't inspire confidence!
(Marc H. Donner and David H. Jameson, "Language and Operating System Features for Real-time Programming", Computing Systems vol 1 number 1, winter 1988, pp 33-62):
> Ill-chosen abstraction is particularly evident in the design of the Ada runtime system. The interface to the Ada runtime system is so opaque that it is impossible to model or predict its performance, making it effectively useless for real-time systems.
More:
https://catless.ncl.ac.uk/Risks/6/36#subj12
> Am I correct in thinking that several (two?) missiles were recently destroyed on launch each of which had their guidance systems coded in Ada? Were the problems which forced the destruction of the missiles the result of bad software design or some inherent ambiguity in Ada syntax?
> I spotted but unfortunately left unlogged a report somewhere which gave an account of a talk by a leading scientist (name?) in the military technology area who expressed grave reservations about the design of Ada. I think the report mentioned that the person expressed little confidence in guidance systems coded in Ada.
Very strange to hear/read about non implementability of hard real-time with Ada when one the guy I hired years ago was one of the OS-for-aircraft-embedded-computer, doing that since the 90s...
You could make the exact same argument about C if you wanted. C's standard library, as implemented for most operating systems, is poorly suited for real-time systems too. That's why it's modified to be fit for purpose when targeting them.
Whether people know it or not, they've been living in the Ada world for a long time. A good deal of the world's critical real-time systems have been running on Ada for decades. Flight, and fire control systems in aircraft, Many major ATC systems, etc. The list goes on, and on.
> After a number of top-secret meetings at the highest levels, the "Ada Project" was conceived. ... Its goal was to divert Soviet attention from truly productive computer languages like Lisp, and convince them that only a bloated, grossly inefficient, high order compiled language along the lines of PL/I could be reasonably utilized in the deployment of military embedded systems. The use of a standardized, inefficient language would provide a one-two punch: it would render super-programmers useless, and it would increase the demands on hardware by more than two orders of magnitude.
> The Ada Project was inspired by the unexpected success of the IBM System/360 architecture behind the Iron Curtain. The Ada Project's wizards {the Ada Project was conceived at Kirtland AFB, NM, near Roswell} reasoned that if the Soviets could be lured into copying the 360 architecture, they could also be lured into copying the Ada language, and if this language were fiendishly designed to make real-time systems essentially impossible to program, then the Soviet military machine would grind to a halt.
> Although Ada would also severely impact American software productivity, it was felt that--just as cancer-fighting chemotherapy nearly kills healthy tissue while it kills tumors--the healthier US economy would be better able to bear the severe burden of an unproductive software industry than the Soviet economy could. Thus, while American geeks were inferior to Soviet geeks, our Elbonian hordes could beat their Mongolian hordes.
Presumably modern Ada is better! Even the sarcastic paper hints at it:
> Now that the Wicked Witch of the East is dead, the wizards have finally allowed Ada to evolve into Ada9X, which fixed some of Ada's more egregious dysfunctions. However, even today the brilliance of Ada's original conception still shines brightly through.
This comment didn't age well. If you've ever been a passenger on a modern jetliner you've most likely trusted your life to real-time systems coded in Ada.
> "Am I correct..."
> "Were the problems..."
> "...by a leading scientist (name?)..."
> "I think the report..."
Terrible. Entirely conjecture. Not one concrete source to substantiate these claims.
These tools are enablers. Would it be nice to have an all-Ada compiler? Well, no! I want most of the gcc engineers to work for me! As long as the gcc backend improves, I get more perf! As long as SMT tools improve I get faster automated proof of contracts, or automated proof of far more complex contracts!
http://www.rvs.uni-bielefeld.de/publications/Incidents/DOCS/...