LWN: Comments on "Maintainer opinions on Rust-for-Linux" https://lwn.net/Articles/1007921/ This is a special feed containing comments posted to the individual LWN article titled "Maintainer opinions on Rust-for-Linux". en-us Fri, 19 Sep 2025 22:19:30 +0000 Fri, 19 Sep 2025 22:19:30 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net nullability annotations in C https://lwn.net/Articles/1010661/ https://lwn.net/Articles/1010661/ farnz Note that Rust's <tt>unsafe</tt> does not turn off complaints; it gives you access to abilities that you can use unsoundly, but just adding <tt>unsafe</tt> to code that Rust rejects will not normally cause it to accept it. Tue, 18 Feb 2025 16:11:11 +0000 nullability annotations in C https://lwn.net/Articles/1010530/ https://lwn.net/Articles/1010530/ anton Porting from malloc()/free() to garbage collection is easy: just delete the calls to free() (or define them as noops). There is one pathological case for conservative garbage collectors (a linked list that grows at the end where you move the root pointer along the list; any spurious pointer to some element will cause the list to leak), but it's a rare idiom. <p>Concerning porting from malloc()/free() to something that guarantees no dangling pointers, no double free() and maybe no leaking: The programmer who uses free() uses some reasoning why the usage in the program is correct. If the new memory-management paradigm allows expressing that reasoning, it should not be hard to port from malloc()/free() to the new memory-management paradigm. One problem here is that not free()ing malloc()ed memory is sometimes a bug (leakage) and sometimes fine; one can mark such allocations, but when the difference is only clear in usage of functions far away from the malloc(), that's hard. Tue, 18 Feb 2025 08:40:05 +0000 nullability annotations in C https://lwn.net/Articles/1010529/ https://lwn.net/Articles/1010529/ anton My understanding (from hearing a talk by George Necula) is that the Ivy tools would complain if they do not know anything about array bounds. And that you can turn off such complaints for parts of the source code that you have not enhanced with annotations yet, like Rust's <code>unsafe</code>. Tue, 18 Feb 2025 08:16:41 +0000 nullability annotations in C https://lwn.net/Articles/1010485/ https://lwn.net/Articles/1010485/ daroc <div class="FormattedComment"> Yes, I agree with that. Existing code is difficult to port over to an entire new memory-management paradigm no matter which way you do it.<br> </div> Mon, 17 Feb 2025 22:48:02 +0000 Too much kool-aid https://lwn.net/Articles/1010484/ https://lwn.net/Articles/1010484/ mirabilos <div class="FormattedComment"> Ah! I heard of it but have never seen it. Thanks!<br> </div> Mon, 17 Feb 2025 22:42:23 +0000 nullability annotations in C https://lwn.net/Articles/1010477/ https://lwn.net/Articles/1010477/ Cyberax <div class="FormattedComment"> Vale is certainly interesting, especially if you're writing new code in that style, but I doubt that it can ever be used to rewrite existing code that heavily depends on mutations spanning regions.<br> <p> I really doubt that the status quo (borrow checker or GC) is going to change. We probably will get more powerful primitives compatible with the borrow checker, though.<br> </div> Mon, 17 Feb 2025 22:13:48 +0000 Too much kool-aid https://lwn.net/Articles/1010474/ https://lwn.net/Articles/1010474/ excors <div class="FormattedComment"> That appears to be Ratfor, which is a Fortran preprocessor that lets you use more C-like syntax. (Ratfor was developed by Brian Kernighan and based on Dennis Ritchie's C, before they became K&amp;R.)<br> </div> Mon, 17 Feb 2025 21:55:44 +0000 Too much kool-aid https://lwn.net/Articles/1010469/ https://lwn.net/Articles/1010469/ mirabilos <div class="FormattedComment"> I have no idea what programming language that even is. (I know there’s also a version in Limbo, for Inferno…)<br> <p> No, we’re talking about the 32V-based one.<br> <a href="https://mbsd.evolvis.org/cvs.cgi/src/usr.bin/oldroff/nroff/">https://mbsd.evolvis.org/cvs.cgi/src/usr.bin/oldroff/nroff/</a> still shows some of the horrors.<br> </div> Mon, 17 Feb 2025 21:23:32 +0000 nullability annotations in C https://lwn.net/Articles/1010457/ https://lwn.net/Articles/1010457/ daroc <p> There's <a href="https://github.com/HigherOrderCO/HVM">one project</a> I've had my eye on that essentially replaces garbage collection with incremental copying and linear references. It's definitely not ready for production use yet, and is arguably still a form of garbage collection even though there's no pauses or separate garbage collector, but it's an interesting approach. Then there's languages like <a href="https://vale.dev/">Vale</a> that are experimenting with Rust-like approaches but with much better ergonomics. </p> <p> None of which means you're wrong — your options right now are basically garbage collection, Rust, or manual memory management — but I do feel hopeful that in the future we'll see another academic breakthrough that gives us some additional options. </p> Mon, 17 Feb 2025 20:11:27 +0000 nullability annotations in C https://lwn.net/Articles/1010428/ https://lwn.net/Articles/1010428/ Cyberax <div class="FormattedComment"> The fundamental problem of memory safety is that you can't have it without either having a garbage collector (or its equivalent), or by statically proving that the lifetimes of the objects are correct.<br> <p> Ivy uses a garbage collector.<br> <p> C just offloads the safety proof to the developer. Rust is really the first language that tries to _assist_ users with proving the lifetime correctness. <br> <p> What's worse, there is no real way to make it much more different from Rust. Any other attempt to implement the lifetime analysis will end up looking very similar. We already see that with SPARK in Ada: <a href="https://blog.adacore.com/using-pointers-in-spark">https://blog.adacore.com/using-pointers-in-spark</a> <br> <p> </div> Mon, 17 Feb 2025 19:13:02 +0000 nullability annotations in C https://lwn.net/Articles/1010426/ https://lwn.net/Articles/1010426/ mbunkus <div class="FormattedComment"> Any type of annotation that's optional won't get used consistently, if ever. It's just human nature. We forget, we are too lazy, we're too friggin' busy figuring out that logic bug. Us humans are just very, very bad at always thinking of all the things we absolutely have to think about. With programming we already have a lot to think about all the time, from language rules to API design to the logic we're currently implementing. Optional things on top of that will fall by the wayside.<br> <p> Just look at most C/C++ code bases (other languages, too) &amp; observe how many variables aren't marked "const" that easily could be. Or how many functions could be "static" but aren't. Or that the default is to copy pointers instead of moving them.<br> <p> Rust has the huge advantage of having made the safe choices the default ones instead of the optional ones, and the compiler helps us remembering when we forget. In C/C++ all defaults are unsafe, and there's almost no help from the compiler.<br> </div> Mon, 17 Feb 2025 19:03:12 +0000 nullability annotations in C https://lwn.net/Articles/1010396/ https://lwn.net/Articles/1010396/ anton There was a research project at Berkeley (George Necula et al.) across several years (including 2006), apparently called Ivy (although early presentations did not use that name). The idea was that existing C code could be made safe piecewise (which requires sticking with the ABI among other things, unlike C implementations with fat pointers) by adding annotations in some places. <p>The compiler would either prove that the code is safe or insert run-time checks, based on a sophisticated type system. I.e., one would get what rewriting in Rust gives, but one would need less effort, and could do it piecewise. <p>This work sounded promising, but there has not been the transfer from the research project into production. Instead, after the research project ended, even the results of the research project mostly vanished (many dead links). What I found is the <a href="http://ivy.cs.berkeley.edu/ivywiki/uploads/">Ivy package, Deputy and Heapsafe manual</a>. But <p>Instead of adding such annotations to C, people started to rewrite stuff in Rust, which seems to be a more expensive proposition. My current guess is that it's a cultural thing: Many, too many C programmers think their code is correct, so there is no need to add annotations that may slow down the code. And those who think otherwise have not picked up the Ivy ideas, but instead switched to Rust when that was available. Mon, 17 Feb 2025 18:02:37 +0000 nullability annotations in C https://lwn.net/Articles/1010257/ https://lwn.net/Articles/1010257/ khim <p>How is that relevant? Linux kernel was all too happy to adopt features not implemented by clang, and patches needed to support clang – and clang, at that point, was already used by Android, the most popular Linux distrubution used by billions… why RHEL should be treated differently?</p> <p>Let RHEL developers decide what to do with their kernel: they can create special kgcc package (like they already did years ago) or rework features in any way they like.</p> Mon, 17 Feb 2025 09:15:04 +0000 nullability annotations in C https://lwn.net/Articles/1010256/ https://lwn.net/Articles/1010256/ taladar <div class="FormattedComment"> It is relevant for the language features that can be used in code backported to the versions of software used in their distro, the entire point of this discussion thread. Or rather the language features that can not be adopted yet because people who want to do those backports will complain.<br> </div> Mon, 17 Feb 2025 08:49:49 +0000 Too much kool-aid https://lwn.net/Articles/1010248/ https://lwn.net/Articles/1010248/ mathstuf <div class="FormattedComment"> Good to hear it's being tackled! Looking at the source code I found[1], it does look quite hairy, but not completely inscrutable.<br> <p> Here's the source of my claim as well: <a href="https://www.youtube.com/watch?v=l6XQUciI-Sc&amp;t=5315s">https://www.youtube.com/watch?v=l6XQUciI-Sc&amp;t=5315s</a><br> <p> [1] <a href="https://9p.io/cm/cs/who/bwk/toolsbook/">https://9p.io/cm/cs/who/bwk/toolsbook/</a><br> </div> Mon, 17 Feb 2025 07:32:31 +0000 Too much kool-aid https://lwn.net/Articles/1010125/ https://lwn.net/Articles/1010125/ mirabilos <div class="FormattedComment"> I’ll have you know I’m using AT&amp;T nroff (under the Caldera licence) and in the process of bringing it sufficiently up to standards that I can build it with newer GCC to run UBSan and Valgrind on it and already found and fixed some issues, yielding quite the speed-up as well.<br> <p> J�rg Schilling (rip.) also used to maintain a fork, similarily.<br> </div> Sat, 15 Feb 2025 23:40:08 +0000 nullability annotations in C https://lwn.net/Articles/1010124/ https://lwn.net/Articles/1010124/ alx.manpages <div class="FormattedComment"> <span class="QuotedText">&gt; I will from now on block you here on LWN and anywhere else.</span><br> <p> Okay. You don't need to. Just asking me to not talk to you would work just fine. I won't, from now on. I won't block you, though.<br> </div> Sat, 15 Feb 2025 23:31:07 +0000 nullability annotations in C https://lwn.net/Articles/1010120/ https://lwn.net/Articles/1010120/ mb <div class="FormattedComment"> <span class="QuotedText">&gt;&gt; Because I put it in quotes.</span><br> <span class="QuotedText">&gt;Please reconsider your language.</span><br> <p> I will from now on block you here on LWN and anywhere else.<br> </div> Sat, 15 Feb 2025 23:12:40 +0000 nullability annotations in C https://lwn.net/Articles/1010117/ https://lwn.net/Articles/1010117/ alx.manpages <div class="FormattedComment"> <span class="QuotedText">&gt; Because I put it in quotes.</span><br> <p> Why did you put it in quotes? Were you implying that my reasoning is inferior than yours? Isn't that offensive? Please reconsider your language.<br> <p> <span class="QuotedText">&gt; And because "I always did it like this" isn't a reasoning that helps in discussions.</span><br> <p> It is, IMO. I'm not a neurologist. Are you? I'm not a expert in how people learn languages and how learning secondary languages isn't as easy as learning a mother tongue. But it is common knowledge that one can speak much better their mother tongue than languages learned after it. It should be those that argue the opposite, who should justify.<br> <p> Or should I take at face value that I learnt the wrong language, and that somehow learning a different one will magically make me write better *without regressions*? What if it doesn't? And why should I trust you?<br> </div> Sat, 15 Feb 2025 23:05:45 +0000 nullability annotations in C https://lwn.net/Articles/1010114/ https://lwn.net/Articles/1010114/ mb <div class="FormattedComment"> Because I put it in quotes.<br> And because "I always did it like this" isn't a reasoning that helps in discussions.<br> </div> Sat, 15 Feb 2025 22:40:52 +0000 nullability annotations in C https://lwn.net/Articles/1010113/ https://lwn.net/Articles/1010113/ alx.manpages <div class="FormattedComment"> Why is "reasoning" quoted?<br> </div> Sat, 15 Feb 2025 22:29:46 +0000 nullability annotations in C https://lwn.net/Articles/1010112/ https://lwn.net/Articles/1010112/ mathstuf <div class="FormattedComment"> Ah, that was the project I was thinking of. I clearly didn't properly internalize its mechanisms when I read that last.<br> </div> Sat, 15 Feb 2025 22:22:09 +0000 nullability annotations in C https://lwn.net/Articles/1009960/ https://lwn.net/Articles/1009960/ mb <div class="FormattedComment"> <span class="QuotedText">&gt;Because C is my "mother tongue"</span><br> <p> That explains your "reasoning" indeed.<br> </div> Sat, 15 Feb 2025 00:51:00 +0000 nullability annotations in C https://lwn.net/Articles/1009954/ https://lwn.net/Articles/1009954/ alx.manpages <div class="FormattedComment"> <span class="QuotedText">&gt; Why not use an interpreted language then?</span><br> <p> Because C is my "mother tongue" regarding computers. I can write it much better than other languages, just like I can speak Valencian better than other --possibly easier-- languages.<br> </div> Sat, 15 Feb 2025 00:24:49 +0000 nullability annotations in C https://lwn.net/Articles/1009953/ https://lwn.net/Articles/1009953/ mb <div class="FormattedComment"> <span class="QuotedText">&gt;I never cared about optimized code. I only care about correct code. </span><br> <p> Why not use an interpreted language then?<br> <p> <span class="QuotedText">&gt;My string library has helped find and fix many classes of bugs ...</span><br> <p> Sure. Thanks for that.<br> Modern languages do that for free, though.<br> <p> <span class="QuotedText">&gt;but the library makes it quite difficult.</span><br> <p> Modern languages make it about impossible.<br> </div> Sat, 15 Feb 2025 00:12:35 +0000 C arcange knowledge, bus factor https://lwn.net/Articles/1009948/ https://lwn.net/Articles/1009948/ alx.manpages <div class="FormattedComment"> <span class="QuotedText">&gt; I hope your projects survive you moving on. Projects using arcane knowledge to hold themselves up are at risk</span><br> <p> That's a valid concern. I try to educate the other co-maintainers and regular contributors on those matters. But I should be more careful on that effort, just in case.<br> </div> Fri, 14 Feb 2025 23:45:22 +0000 nullability annotations in C https://lwn.net/Articles/1009945/ https://lwn.net/Articles/1009945/ Cyberax <div class="FormattedComment"> Runtime checks won't help you for things like use-after-free. You really need a full-blown GC, and fat pointers that encode the block lengths.<br> <p> There _are_ attempts to do that with C. I know of this one: <a href="https://github.com/pizlonator/llvm-project-deluge/blob/deluge/Manifesto.md">https://github.com/pizlonator/llvm-project-deluge/blob/de...</a><br> <p> </div> Fri, 14 Feb 2025 23:39:01 +0000 Too much kool-aid https://lwn.net/Articles/1009943/ https://lwn.net/Articles/1009943/ mathstuf <div class="FormattedComment"> <span class="QuotedText">&gt; I know the language so damn well that that offsets the theoretical benefits that Rust could give me.</span><br> <p> I hope your projects survive you moving on. Projects using arcane knowledge to hold themselves up are at risk of becoming like one of the `roff` implementations (`nroff`?): inscrutable to even the other Unix prophets so as to be left alone after the original author's untimely end[1].<br> <p> [1] At least if my memory of a BSD podcast which interviewed Bryan Cantrill where it was mentioned is accurate.<br> </div> Fri, 14 Feb 2025 23:33:19 +0000 nullability annotations in C https://lwn.net/Articles/1009942/ https://lwn.net/Articles/1009942/ mathstuf <div class="FormattedComment"> <span class="QuotedText">&gt; There's a reason why -fanalyzer works reasonably well in C and not in C++.</span><br> <p> Yes, I agree. However, IIRC, it is because its main author (David Malcolm) is vastly more familiar with C than C++. Clang also has something like it in some of its `clang-tidy` checks, but I agree that GCC's definitely has a different set of things it covers, so they can coexist nicely.<br> </div> Fri, 14 Feb 2025 23:30:07 +0000 nullability annotations in C https://lwn.net/Articles/1009940/ https://lwn.net/Articles/1009940/ mathstuf <div class="FormattedComment"> There's another effort like this (apparent slideware). It does it by, AFAICT, inserting a VM between the code and the hardware to do runtime checks on everything. Its performance is…about what one would expect for such an endeavor (IIRC, 10x penalty). Alas, Firefox history search is not surfacing it by any details I remember.<br> </div> Fri, 14 Feb 2025 23:28:32 +0000 Rust tutorial via mailing list https://lwn.net/Articles/1009872/ https://lwn.net/Articles/1009872/ sarahn <div class="FormattedComment"> Speaking for myself only, I was not making the time to learn rust without external prompting. I signed up for a 10 week remote UCSC extension course on rust.<br> <p> Since UCSC offers or has offered courses on both Linux device drivers and on rust, they could probably be convinced to offer a "rust for Linux device driver developers" course.<br> </div> Fri, 14 Feb 2025 18:36:41 +0000 Uses of termination checking https://lwn.net/Articles/1009781/ https://lwn.net/Articles/1009781/ farnz Idris has both as part of its totality checker; a function can be partial (in which case it may never terminate or produce a value - it can crash or loop forever) or total (in which case it must either terminate for all possible inputs, or produce a prefix of a possibly infinite result for all possible inputs). <p>Idris then uses this to determine whether it can evaluate a function at compile time (total functions) or whether it must defer to runtime (partial functions). This becomes important because Idris is dependently typed, so you can write a type that depends on the outcome of evaluating a function; if that function is total, then the type can be fully checked at compile time, while if it's partial, it cannot. Fri, 14 Feb 2025 15:27:57 +0000 Running several checkers instead of one https://lwn.net/Articles/1009775/ https://lwn.net/Articles/1009775/ taladar <div class="FormattedComment"> Maybe there is also a place for termination checking that doesn't cover the entire program? It could limit where you have to look for bugs similar to unsafe blocks or the way test coverage is displayed.<br> </div> Fri, 14 Feb 2025 15:12:53 +0000 nullability annotations in C https://lwn.net/Articles/1009767/ https://lwn.net/Articles/1009767/ khim <p>Who even cares what they use for he development of the platform itself?</p> <p>Developers shouldn't even care about that, it's internal implementations detail.</p> Fri, 14 Feb 2025 14:29:45 +0000 nullability annotations in C https://lwn.net/Articles/1009766/ https://lwn.net/Articles/1009766/ taladar <div class="FormattedComment"> Your link goes to the Developer Toolset, those are optional tools that can be used on the platform but are not used for the platform itself.<br> </div> Fri, 14 Feb 2025 14:26:17 +0000 It can still crash https://lwn.net/Articles/1009686/ https://lwn.net/Articles/1009686/ tialaramex <div class="FormattedComment"> Yes, if you use method call syntax (remember this is optional, although it will be more idiomatic in most cases to use method call syntax, Rust can express any method call as an ordinary function call despite not having full blown Universal Method Call Syntax) the transformation makes the appropriate reference types automatically (and so if it couldn't under Rust's borrowing rules that won't compile)<br> <p> This will also happen if you use an operator, take AddAssign the trait implementing the += operator<br> <p> description += " and then I woke up.";<br> <p> ... Is eventually just AddAssign::add_assign(&amp;mut description, " and then I woke up.");<br> <p> So if we lent out any reference to description that's still outstanding, we can't do this, likewise if we only have an immutable reference we can't use that to do this either. But the visible syntax shows no sign that this is the case.<br> <p> In practice because humans are fallible, the most important thing is that this is checked by the compiler. It's valuable to know that my_function takes a mutable reference, when you're writing the software, when you're reading software other people wrote, and most definitely when re-reading your own software - but it's *most* valuable that the compiler checks because I might miss that, all three times.<br> </div> Fri, 14 Feb 2025 12:01:12 +0000 Running several checkers instead of one https://lwn.net/Articles/1009682/ https://lwn.net/Articles/1009682/ farnz If you run all the currently known termination checker algorithms that actually come up with useful results (with the exception of "run until a timeout is hit, say it might not terminate if the timeout is hit, or it does terminate if the timeout is not hit"), you're looking at a few seconds at most. The pain is not the time that the algorithms we know of take, it's the fact that most of them return "undecided" on programs that humans can tell will terminate. Fri, 14 Feb 2025 11:02:18 +0000 Errors on close https://lwn.net/Articles/1009680/ https://lwn.net/Articles/1009680/ farnz But, by the nature of Linux's <tt>close</tt> syscall, error on close means one of three things: <ol> <li>You supplied a bad file descriptor to close. No data loss, nothing to do. <li>A signal came in mid-close. No data loss, nothing to do. <li>You're on NFS, and a previous operation failed - but you don't know which one, or whether the data is safe. </ol> <p>Deleting the file is the worst possible thing to do with an error on close - two of the three are cases where the data <em>has</em> been saved, and it's an oddity of your code that resulted in the error being reported on close. The third is one where the file is on an NFS mount, the NFS server is set up to write data immediately upon receiving a command (rather than on <tt>fsync</tt>, since you won't get a delayed error for a write if the NFS server is itself caching) and you didn't <tt>fsync</tt> before <tt>close</tt> (required on NFS to guarantee that you get errors). <p>But even in the latter case, <tt>close</tt> is not enough to guarantee that you get a meaningful error that tells you that the data has not been saved - you need <tt>fsync</tt>, since the NFS server is permitted to return success to all writes and closes, and only error on <tt>fsync</tt>. <p>And just to be completely clear, I think this makes error on close useless, because all it means in most cases is either "your program has a bug" or "a signal happened at a funny moment". There's a rare edge case if you have a weird NFS setup where an error on close can mean "data lost", but if you're not in that edge case (which cannot be detected programmatically, since it depends on the NFS server's configuration), the two worst possible things you can do if there's an error on close are "delete the file (containing safe data) and start over" and "report to the user that you've saved their data, probably, so that they can take action just in case this is an edge case system. <p>On the other hand, <tt>fsync</tt> deterministically tells you either that the data is as safe as can reasonably be promised, or thatit's lost, and you should take action. Fri, 14 Feb 2025 10:49:07 +0000 nullability annotations in C https://lwn.net/Articles/1009587/ https://lwn.net/Articles/1009587/ Cyberax <div class="FormattedComment"> <span class="QuotedText">&gt; This reminds me of Esperanto. Such a great language that everybody should learn it. If it works for you, that's great, but please don't tell me which language is safer _for me_. I know better.</span><br> <p> No, you don't. No human can keep track of all of the C pitfalls in non-trivial code.<br> <p> Even the most paranoid DJB code for qmail had root holes, and by today's standards it's not a large piece of software.<br> </div> Thu, 13 Feb 2025 19:05:09 +0000 Running several checkers instead of one https://lwn.net/Articles/1009575/ https://lwn.net/Articles/1009575/ daroc <div class="FormattedComment"> Sure, but there's a mathematical proof that any set of checkers you can make will have some programs that they can't decide. It's not just a matter of finding the right one.<br> <p> So the tradeoff will always be between not being able to check this property, or being able to check it but rejecting some programs that are probably fine.<br> <p> That said, I do think there is a place for termination checking in some languages — the fact that Idris has it lets you do some really amazing things with dependent typing. Whether _Rust_ should accept that tradeoff is a matter of which things it will make harder and which things it will make easier, not just performance.<br> </div> Thu, 13 Feb 2025 18:31:49 +0000