Yes, same old buffer C/C++ overflow problem. We have mainstream alternatives now. C#. Go. Rust. It's time to move on.
Yes, same old buffer C/C++ overflow problem. We have mainstream alternatives now. C#. Go. Rust. It's time to move on.
If they haven't kept up with the changes in their current language, what makes one think that they would "move on" to the alternatives, two of which aren't even alternatives?
Before they switch to Rust it would be much faster and more efficient to use smart pointers, std::array, std::vector and stop using memcpy.
Naturally when one writes C in C++ it doesn't help.
To me it's that this extremely trivial bug (the heap overflow, let's ignore the rest for now) passed through code review, security review, security audits, fuzzing... Or that Apple didn't have these in place at all. Not sure which option is worse.
Safe languages are the only way forward to drastically reduce the problem. It can’t be guaranteed to be eliminated 100% obviously because there are still escape hatches available, but it will be significantly improved because you can limit the surface area where such bugs can live.
If it's taken someone a whole fortnight to write it, you should expect to spend at least half a day reviewing it, IMO.
To me, this strongly suggests that the problem is in fact memory-unsafe languages, and not general engineering practices.
Apple, by the way, has all the things you're talking about in place, and in spades.
You can improve the tools, or you can improve the human, and nobody has managed to improve the human despite decades of trying.
In practice, the best case and average case rarely line up.
Languages don't introduce bugs by themselves. Engineers produced those bugs.
I always thought that bugs are the programmers' fault, and not to blame the language. It's like blaming the English language because it allows you to misuse it and manufacture very offensive racial slurs, or to be rude and cruel, and thus we should replace it with another language that doesn't allow to exploit these weaknesses. We won't be able to express ourselves with beautifully (low-level) crafted poems anymore, but that's the price to pay.
In Hungarian we don't have this problem at all, there's no concept of gender specific pronouns.
Thankfully, Apple is starting to hire Rust developers as well as AWS.
The tide is changing, one day we will see some Rust code in iOS/macOS so that these issues are a thing of the past.
It seems much more likely that they will use Swift in some form.
There is reason to believe they will adapt it.
That being said, ARC is probably easier to get to work well in-kernel vs. tracing garbage collection. There's a performance cost to all of those reference count updates, but at least the variance is extremely low.
> Swift is a successor to both the C and Objective-C languages.
https://developer.apple.com/swift
> Swift is intended as a replacement for C-based languages (C, C++, and Objective-C).
There are people that believe systems programming languages in an OS kernel is doable with some form of GC, and then there those that will never change their mind.
https://www.f-secure.com/en/consulting/foundry/usb-armory
https://blog.arduino.cc/2019/08/23/tinygo-on-arduino/
https://github.com/mit-pdos/biscuit
https://github.com/ycoroneos/G.E.R.T
By the way, NeXTSTEP drivers were written in Objective-C, and the new userspace framework, DriverKit, is an homage to the NeXTSTEP driver API.
https://www.nextop.de/NeXTstep_3.3_Developer_Documentation/O...
That being said, ARC may faire much better than a tracing GC, particularly in latency variance, throughput variance, and mean heap usage.
Though, I think we're best off moving off of hypervisors and onto 4th generation microkernels with isolation similar to AIX LPARs / Solaris Containers. After all, a hypervisor is essentially a microkernel that's forced to use hardware traps/faults plus hardware emulation for its syscall interface (plus upcalls for performance, which use a calling convention much closer to traditional syscalls). There are stability, security, and performance advantages to throwing out all of that hardware emulation code, moving everything to upcalls, and getting rid of the second (guest OS) kernel running between the application and the hardware. If you push most of the system functionality out of kernel space, then rewriting some of the less performance-critical components in a language with ARC or tracing GC starts to make more sense.
Biscuit was a research project whose goal was to get the thesis done, when the thesis was done, no more effort was spent.
Bing was powered by Midori for the Asian countries for part of its life, and Joe Duffy has stated in the RustConf keynote that Windows Dev team was a reason why Midori faced so much internal resistance, even when they were proven wrong.
Before Google was willing to put the money into JavaScript many would assert that JavaScript would be worthless to anything besides form validation and DHTML.
Mainframes to this day still make use of their own systems programming languages, way safer than C, and you don't see people crying that their kernels are too slow.
In fact, Unisys uses this fact to sell ClearPath MCP to customers that value security above anything else, Fort Knox style.
Burroughs MCP was written in essentially an extended Algol 60 dialect. Algol 60 only had very limited heap allocation for dynamic arrays, no GC, and I haven't read any indications that Burroughs added GC to their extended dialects.
Multics was written in a PL/I dialect, without tracing GC. Likewise, IBM OS/360 and descendants are written in the PL/S dialect of PL/I, and I haven't seen any indication it has tracing GC.
With tracing GC, you have a trade-off between the peak amount of unclaimed garbage and the GC overhead. ARC should have lower variance in both latency and heap usage, which I presume is the reason Apple moved the whole Objective-C and Swift ecosystem to ARC and deprecated the Objective-C tracing GC.
I used to be a True Believer(tm) in the JVM and other managed runtimes. I was one of 5 developers of the most popular Java desktop application in the mid 2000s. Then I moved to Google and started developing web search infrastructure. I was at Google when V8 was created, and I put a lot of effort into running all of the JavaScript that the indexing system found, across the entire visible web. For things at massive scale, spending millions of dollars per year just in electricity bills, it's extremely tough to beat highly tuned C++. Yes, it's a lot of effort. Yes, I hope safer languages like Rust replace C++ and static analysis tools continue to improve.
I still kind of want to be a managed runtime true believer again, but it's tough to go back after believing for so many years that managed runtimes were going to match expertly hand-optimized C++ in latency- and throughput-critical applications "any day now".
Fortunately there are enough true believers to keep them in business.
By the way, apparently it is time for Google to improve their gRPC C++ implementation.
https://devblogs.microsoft.com/aspnet/grpc-performance-impro...
As for the mainframe languages, yes they don't have a GC, but they have the right defaults regarding bounds checking, implicit conversions, explicit unsafe code.
Regarding managed runtimes, versus C++, languages like C#, D, Modula-3, Swift have the features to write C++ like code when needed, the main problem is that many don't bother to learn the language features available to them.
At Microsoft stories about hard core C++ devs having to be proven wrong with C# running in front of them is relatively known, Joe Duffy has shared a couple of such stories.
His experience in Singularity and Midori is also what made him bet on Go for Pulumi.
There's so much low-hanging fruit to pick in that code and switching to Rust is like saying that we should go to Mars to pick fruit instead.
So much that many of the System C# features are now in .NET 5 and other ones will eventually land on .NET 6.
Also on another front Apple seems to have already enabled device drivers in user space: https://developer.apple.com/system-extensions/
But you definitely cannot build a performant and robust kernel from scrtach with these languages.
I think this is irrelevant (and less importantly, false). Its's fine to use eg se4l as a foundation, or as a incremental step even just have a safety focused driver runtime inside the kernel proper.
https://www.wildernesslabs.co/
https://en.m.wikipedia.org/wiki/Singularity_(operating_syste...
I agree rust is probably better suited. Or Apple could make their own memory safe language. They’re clearly capable.
I just wonder, for example, how a capable hardware abstraction layer would work in C#, interrupt handling, CPU and IO scheduling, etc.
Go: GC again, so no go.
Rust: most sane of the examples you've given.
Apple has already started migrating to Swift which is a memory safe language.
However the real reasons Rust and Go aren't feasible is that they're both essentially all-or-nothing, and neither offers even the most basic semblance of ABI compatibility. Their only nod to ABI stability is "use FFI to C" which means your APIs remain unsafe, and doesn't work for non-C languages without all your system APIs having other languages layered on top.
Swift at least lets you replace individual objc classes one at a time, and is ABI stable, but has no C++ interaction.
XNU also has ABI stability requirements which rules out rust.
The basic trick for backwards compatibility is that all arrays have sizes, but you get to specify the expression which represents the size and associate it with the array. So you don't need array descriptors and can keep many existing representations.
Also, if you have slices, you rarely need pointer arithmetic. Slices are pointer arithmetic with sane semantics.
I'm tired of seeing decade after decade of C/C++ buffer overflows. It speaks badly of software engineering as a profession.
[1] http://www.animats.com/papers/languages/safearraysforc43.pdf
> Gets added to Visual C/C++, LLVM, and Gnu C as an extention.
And had to do a double-take because I thought you were talking about gets(3)…
But yeah, it only works if you use those types.
There are other divisions pushing for .NET and Rust systems code in Windows, but the political wars between WinDev and DevTools are quite well known, e.g. Longhorn (in .NET) vs WinRT (same thing just in COM).