News for hackers. Stuff that matters.
Re:Teardown of a Failed Linux LTS Spectre Fix by kevin_thibedeau on Wednesday September 04, 2019 @11:29AM (#20878082)
C++ is broken without exceptions. Exceptions aren't ever going to enter the kernel even if you tried to hide them behind a C ABI.
Re:Teardown of a Failed Linux LTS Spectre Fix by nickpsecurity on Wednesday September 04, 2019 @02:55PM (#20880288)
The folks behind the Pistachio microkernel said they used C++:

https://github.com/l4ka/pistachio

I don't know if it has exceptions or an unusual style since I don't know C++. It is written by CompSci researchers which usually means a different style. Just throwing it out there for anyone considering C++ in kernels since the L4 kernels were all really fast and lean.

Re:Teardown of a Failed Linux LTS Spectre Fix by kevin_thibedeau on Wednesday September 04, 2019 @03:18PM (#20880497)
And Google merrily uses C++ with exceptions disabled. That doesn't make it right when the shit hits the fan. "Works most of the time" is not acceptable in an OS.
Re:Teardown of a Failed Linux LTS Spectre Fix by kevingadd on Wednesday September 04, 2019 @08:58PM (#20882925)
Would you seriously argue that "works most of the time" does not describe C? Or are you just saying that accepting it for another language is not okay, and anything new allowed into the kernel needs to be perfect instead of just better than C?
Re:Teardown of a Failed Linux LTS Spectre Fix by nickpsecurity on Wednesday September 04, 2019 @03:23PM (#20880538)
Your statement equates not using exceptions with no error handling at all. Are exceptions the only way C++ can handle errors? Or can it do things like return codes used in C or advanced constructs via its metaprogramming?
Re:Teardown of a Failed Linux LTS Spectre Fix by tomjakubowski on Wednesday September 04, 2019 @10:24PM (#20883343)
You can use error codes or, better, a Result<T, E> template in C++, but throwing an exception is the only sane way to signal an error from a C++ constructor that I know of. The alternatives are awkward: you either stick an error code on the struct, which the caller can check after construction, or write an error code to the caller through an out parameter. In either case, the class implementation now must be concerned with handling objects in some partly-initialized, "error" state.
Re:Teardown of a Failed Linux LTS Spectre Fix by ncmncm on Thursday September 05, 2019 @02:28AM (#20884335)
Error handling without exceptions tends to 3x to 5x as much raw code, with corresponding numbers of errors and poorly-exercised paths. Exception paths rely mostly on destructors which are otherwise well-tested in normal operation.