LWN: Comments on "Announcing Arti, a pure-Rust Tor implementation (Tor blog)" https://lwn.net/Articles/862329/ This is a special feed containing comments posted to the individual LWN article titled "Announcing Arti, a pure-Rust Tor implementation (Tor blog)". en-us Thu, 18 Sep 2025 00:53:47 +0000 Thu, 18 Sep 2025 00:53:47 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863943/ https://lwn.net/Articles/863943/ immibis <div class="FormattedComment"> No, it simply means &quot;or&quot;. As in:<br> <p> <font class="QuotedText">&gt; So you are either one of the very rare programmers whose mental capacity is sufficient to write C or C++ code without introducing subtle memory errors.</font><br> <p> These are both languages where it&#x27;s possible to introduce subtle memory errors, and the statement suggests that the person in question is capable of understanding their program&#x27;s memory management well enough to not introduce them.<br> </div> Thu, 22 Jul 2021 10:43:40 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863942/ https://lwn.net/Articles/863942/ immibis <div class="FormattedComment"> This sounds like it has exactly the same problem as Python. Does the build script work on every Linux distribution?<br> </div> Thu, 22 Jul 2021 10:42:09 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863894/ https://lwn.net/Articles/863894/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; &gt; Is the former acceptable?</font><br> <p> <font class="QuotedText">&gt; &quot;Acceptable&quot; is just a point on the cost/benefit curve.</font><br> <p> Sure, what I meant was: should anything at all be done about memory corruption? The answer is yes of course - and it is being done in some places and not just with Rust. Exciting times.<br> <p> <font class="QuotedText">&gt; Until then, it will be ignored unless an external entity (eg government regulation or payment card or insurance carrier requirement) forces an organization to proactively care.</font><br> <p> In general yes of course but there a few exceptions like Microsoft, Google and a few other &quot;SmallTech&quot;. Check the Microsoft slides linked above.<br> <p> </div> Wed, 21 Jul 2021 22:25:09 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863867/ https://lwn.net/Articles/863867/ pizza <div class="FormattedComment"> <font class="QuotedText">&gt; Is the former acceptable?</font><br> <p> &quot;Acceptable&quot; is just a point on the cost/benefit curve.<br> <p> Clearly it has been acceptable. And, to be blunt, it will continue to be, for the same reason that the financial industry still runs on COBOL -- Rewriting the billions of lines of existing &quot;inherently unsafe&quot; code into &quot;memory-safe&quot; languages will cost a *lot* more money (and introduce far more new bugs along the way) than the current practice of (semi-proactively) plugging holes and cleaning up messes after the fact.<br> <p> The costs of &quot;security vulnerabilities&quot; are nearly always external (ie someone else&#x27;s problem). That vulnerability only becomes an &quot;incident&quot; is when an organization directly incurs some cost. Until then, it will be ignored unless an external entity (eg government regulation or payment card or insurance carrier requirement) forces an organization to proactively care.<br> </div> Wed, 21 Jul 2021 17:27:22 +0000 Ownership and lifetimes https://lwn.net/Articles/863557/ https://lwn.net/Articles/863557/ anton Concerning integer overflow, the result with a given bit-width is the same for twos-complement arithmetic across all hardware (they all can perform modulo arithmetic, aka wrapping on overflow). And all architectures introduced since 1970 use twos-complement arithmetic exclusively (while, e.g., . So for integer overflow, the behaviour could be just standarized, no need for cop-outs like implementation-defined or implementation-specified. As an example modulo arithmetic has been standardized in Java from the start. Tue, 20 Jul 2021 10:25:53 +0000 Ownership and lifetimes https://lwn.net/Articles/863552/ https://lwn.net/Articles/863552/ anton Backwards-compatible C compilers in the relaxed Linus Torvals sense (if no one notices, it's not breakage) <a href="http://www.complang.tuwien.ac.at/papers/ertl17kps.pdf">are possible and desirable</a>. Tue, 20 Jul 2021 09:58:02 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863549/ https://lwn.net/Articles/863549/ anton Yes, <em>religion</em> is a more appropriate analogue for the attachment that programmers feel to programming languages than <em>Stockholm syndrome</em>. Another phenomenon that may explain the attachment is <em><a href="https://en.wikipedia.org/wiki/Choice-supportive_bias">choice-supportive bias</a></em> (and that may also be related to religion). Tue, 20 Jul 2021 08:55:30 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863360/ https://lwn.net/Articles/863360/ marcH <div class="FormattedComment"> This is a very interesting presentation, thanks for sharing it! I enjoyed it because you really don&#x27;t need to be a security expert to make the most of it, you &quot;only&quot; need to be a software engineer.<br> <p> Among others it explains why attacks rely less often on vulnerabilities and more on other techniques like social engineering. It&#x27;s not because there was much coding and quality progress, in fact it rather depressingly states that developers keep making the same mistakes as before. The main reason is because Microsoft fixes them much faster than ever and made it very difficult to turn off auto updates. This gives a very strong incentive to minimize usage of vulnerabilities and reserve them for discrete, targeted attacks. Auto-updates have basically changed the market of vulnerabilities, their value has increased to the point where only nation states or very rich actors can afford them. I&#x27;m over simplifying of course, open the PDF if you&#x27;re interested in the actual numbers.<br> <p> So I stand corrected: the connection between ransomware and memory safety is probably tenuous... _if_ you use aggressively auto-updated software exclusively! <br> <p> <a href="https://www.theverge.com/2021/1/6/22217052/microsoft-windows-7-109-million-pcs-usage-stats-analytics">https://www.theverge.com/2021/1/6/22217052/microsoft-wind...</a><br> (Windows 7 is still running on at least 100 million PCs)<br> <p> As long as you&#x27;re not a high profile target or you don&#x27;t mind getting spied on by any government or other powerful actor, keep using software written in a memory corruption language. Just make sure there&#x27;s a billion dollars company constantly racing to keep it up to date. <br> <p> Also keep in mind this analysis is based on Microsoft&#x27;s data only.<br> <p> Another interesting point is how effective but still limited mitigations like CFG, CET,... are and how the only way to make them 100% effective &quot;decomposes to needing to solve memory safety&quot;.<br> <p> <p> </div> Mon, 19 Jul 2021 02:36:52 +0000 ncm https://lwn.net/Articles/863344/ https://lwn.net/Articles/863344/ tialaramex <div class="FormattedComment"> It seems plausible that ncm is Nathan Myers, who was, and perhaps still is, an active JTC1/SC22/WG21 (ie C++ Standards Committee) participant. In which case what you&#x27;ve got there is two experts disagreeing.<br> <p> But we are on the Internet, and so it is of course also possible ncm is a dog (I have verified that the committee member was not a dog).<br> <p> In the former case, maybe we can say Nathan is trying to get C++ to a better place. After all, I think implicit constructors were a bad idea, they&#x27;re the wrong default, but they&#x27;re only a default at all because of the &quot;explicit&quot; keyword, which is apparently Nathan&#x27;s idea. So once the situation was &quot;C++ constructors are inexplicably dangerous&quot; and Nathan improved it to &quot;C++ constructors are inexplicably dangerous by default&quot;. The correct fix (an &quot;implicit&quot; keyword) violates C++ backwards compatibility promises and (which of more practical upshot) breaks a bunch of working code. So &quot;explicit&quot; means as long as every C++ programmer is conscientious and never makes a mistake they avoid this particular footgun. &quot;Hooray&quot;.<br> </div> Sun, 18 Jul 2021 21:53:05 +0000 Ownership and lifetimes https://lwn.net/Articles/863339/ https://lwn.net/Articles/863339/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; Stroustrup never, ever rants. When he writes, every word counts. To perceive ranting only demonstrates confusion.</font><br> <p> Whether it&#x27;s true or not, I&#x27;m afraid you don&#x27;t realize how cultish that is perceived.<br> <p> </div> Sun, 18 Jul 2021 18:49:42 +0000 Ownership and lifetimes https://lwn.net/Articles/863338/ https://lwn.net/Articles/863338/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; &gt; I will, in fact, claim that the difference between a bad programmer and a good one is whether he considers his code or his data structures more important. Bad programmers worry about the code. Good programmers worry about data structures and their relationships.</font><br> <p> I think this is because when you read a piece of code, the difficult and error-prone part is the &quot;stateful&quot; part. A child can understand a one page-long function as long it&#x27;s &quot;pure&quot; with only explicit inputs and outputs and no side-effect; it&#x27;s &quot;just maths&quot;!<br> <a href="https://en.wikipedia.org/wiki/Referential_transparency">https://en.wikipedia.org/wiki/Referential_transparency</a><br> <p> But good luck when that one page-long is updating some complex data structure that persists before and after the code is run. Then you need to keep in your head a lot more context and information that is not directly visible on the screen. If on top of that you also need to remember what other pieces code could be performing on the same data _at the same time_ then it&#x27;s game over for most people and even for the smartest is much more cognitive strain. See excors&#x27;s comment about locks etc. at <a href="https://lwn.net/Articles/862591/">https://lwn.net/Articles/862591/</a><br> <p> This is also why writing hardware code is IMHO &quot;harder&quot; than software: hardware design is all about managing a huge number of concurrent states.<br> <p> It&#x27;s about time low-level software takes some elevation and safe (!) distance from hardware design and stops mimicking it because unlike hardware, software has no reason to burden developers with so much micro-management of data states and side effects. Instead, tell the compiler or static analyser who owns or borrows what data and when and let it find the bugs. Yes, that makes compilation much longer but that time is nothing compared to error-prone code reviews that often don&#x27;t happen because no time has been planned for them. Let the machines do the tedious work, they&#x27;re so much better at it.<br> <p> <p> </div> Sun, 18 Jul 2021 18:44:03 +0000 Ownership and lifetimes https://lwn.net/Articles/863337/ https://lwn.net/Articles/863337/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; To believe that C++ is not rapidly growing and changing is to believe a fantasy that C++20 is hardly different from C++17, from C++14, from C++11, from C++03, from C++98.</font><br> <p> OK, so language theory discussions are fascinating (thank you everyone) but now let&#x27;s get real a bit. Let&#x27;s pretend I&#x27;m managing a software team and I&#x27;ve been asked to get rid of most safety issues in the C++ codebase of our mission-critical application. What -Wold-unsafe-c++ compiler flag do I turn on to make sure my not-all-perfect developers don&#x27;t make any mistake and stick to &quot;modern C++&quot;? If that compiler flag is not available, what static analyzer(s) should I use? I have practically unlimited budget so I don&#x27;t mind commercial products. (Even an unlimited budget is unfortunately not enough to hire an elite team of C++ developers who never make any mistake)<br> <p> <font class="QuotedText">&gt; there is no worry about lunch. </font><br> <p> I don&#x27;t think anyone doubts C++ will still make a lot of money after even the youngest people in this discussion are dead, no reason to feel threatened.<br> There is a shortage of developers, not a shortage of code to write. Apparently you can still get paid to fix COBOL code:<br> <a href="https://www.theverge.com/2020/4/14/21219561/coronavirus-pandemic-unemployment-systems-cobol-legacy-software-infrastructure">https://www.theverge.com/2020/4/14/21219561/coronavirus-p...</a><br> <p> </div> Sun, 18 Jul 2021 18:10:19 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863336/ https://lwn.net/Articles/863336/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; There&#x27;s merit in selecting the good parts of prior art and mixing them in a useful way, the same way there&#x27;s merit in meta analysis even when they don&#x27;t create new knowledge.</font><br> <p> I would call this &quot;engineering&quot;.<br> <p> </div> Sun, 18 Jul 2021 17:54:26 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863333/ https://lwn.net/Articles/863333/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; Ah, okay, so that&#x27;s &quot;70% of security vulnerabilities&quot; -- which is *not* the same as &quot;security incidents&quot;.</font><br> <p> Is the former acceptable?<br> </div> Sun, 18 Jul 2021 16:48:32 +0000 Ownership and lifetimes https://lwn.net/Articles/863324/ https://lwn.net/Articles/863324/ flussence <div class="FormattedComment"> Congratulations on becoming the new IBM OpenOffice Guy.<br> </div> Sun, 18 Jul 2021 13:13:00 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863300/ https://lwn.net/Articles/863300/ pizza <div class="FormattedComment"> <font class="QuotedText">&gt; Graph shows a period of 12 years, 2006-2018, showing that around 70% of &quot;security vulnerabilities addressed by a security update&quot;</font><br> <p> Ah, okay, so that&#x27;s &quot;70% of security vulnerabilities&quot; -- which is *not* the same as &quot;security incidents&quot;. <br> <p> (As the 7th &amp; 8th slide in that deck demonstrates, there is a considerable gap between &quot;vulnerabilities&quot; and &quot;exploits&quot;, and the 9th slide says the &quot;market&quot; has moved predominantly to social engineering-based attacks instead)<br> <p> </div> Sun, 18 Jul 2021 01:39:05 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863289/ https://lwn.net/Articles/863289/ ms-tg <div class="FormattedComment"> Further googling also reminds us of the following additional citations that may be of interest:<br> <p> * Microsoft Security Response Center: A proactive approach to more secure code<br> https://msrc-blog.microsoft.com/2019/07/16/a-proactive-approach-to-more-secure-code/<br> (repeats same graph and statistic, introduces the case for Rust in that context)<br> <p> The connection between the cited statistic, and Microsoft&#x27;s exploration of the Rust language, appear to have been widely covered in all sorts of media, for example:<br> <p> * <a href="https://www.zdnet.com/article/microsoft-to-explore-using-rust/">https://www.zdnet.com/article/microsoft-to-explore-using-...</a><br> <p> <p> <p> </div> Sat, 17 Jul 2021 22:43:11 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863288/ https://lwn.net/Articles/863288/ ms-tg <div class="FormattedComment"> Hi pizza, <br> <p> <font class="QuotedText">&gt; I&#x27;d love to see an actual citation for that &quot;70% of all security incidents&quot; thing.</font><br> <p> Here&#x27;s the citation I am aware of:<br> <p> * Matt Miller, an engineer at Microsoft, presented the following talk at the conference Bluehat 2019 in Israel:<br> - VIDEO: <a href="https://www.youtube.com/watch?v=PjbGojjnBZQ">https://www.youtube.com/watch?v=PjbGojjnBZQ</a><br> - SLIDES: <a href="https://github.com/Microsoft/MSRC-Security-Research/blob/master/presentations/2019_02_BlueHatIL/2019_01%20-%20BlueHatIL%20-%20Trends%2C%20challenge%2C%20and%20shifts%20in%20software%20vulnerability%20mitigation.pdf">https://github.com/Microsoft/MSRC-Security-Research/blob/...</a><br> <p> As an aside: this appears to be the same conference at which Andrew &quot;bunnie&quot; Huang delivered the talk &quot;Supply Chain Security: If I were a Nation State…&quot;, which I think I also read about here at LWN.<br> <p> It appears that the citation for the 70% statistic starts at 14:05 into the talk, which corresponds to Slide 11. <br> <p> Graph shows a period of 12 years, 2006-2018, showing that around 70% of &quot;security vulnerabilities addressed by a security update&quot; each year correspond to a memory safety issue. Subsequent slides break those down further into classes of memory safety issues.<br> <p> Hope this helps!<br> </div> Sat, 17 Jul 2021 22:34:29 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863284/ https://lwn.net/Articles/863284/ pizza <div class="FormattedComment"> <font class="QuotedText">&gt; For free time projects you&#x27;re right. But when all businesses tired of ramsomware and other malware finally connect 70% of security incidents with the language of memory corruption and finally ask their providers &quot;Wait, what language did you code this in?&quot;, then it won&#x27;t be up for programmers themselves to decide. Money will talk. Very few programmers get to decide what language is used in $DAYJOB.</font><br> <p> I&#x27;d love to see an actual citation for that &quot;70% of all security incidents&quot; thing.<br> <p> For example. The largest data breach in history (Equifax) was due to an unpatched Apache Struts deployment, written in &quot;no memory corruption&quot; Java.<br> <p> Phishing and general credential theft? Social engineering, not memory corruption.<br> Ransomware? Social engineering and MS Windows treating &quot;opening documents&quot; the same as &quot;executing a binary&quot; (along with awful UI design so the user genuinely can&#x27;t tell the difference most of the time), not memory corruption.<br> SQL injection &amp; XSS vulnerabilities? Improper validating/escaping inputs, not memory corruption<br> SSH/SSL downgrade attacks? Protocol misdesign, not memory corruption<br> IoT botnets? Hard-coded passwords/backdoors, not memory corruption<br> <p> <p> </div> Sat, 17 Jul 2021 21:31:43 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863282/ https://lwn.net/Articles/863282/ marcH <div class="FormattedComment"> It depends how programmers are &quot;filtered out&quot;. For free time projects you&#x27;re right. But when all businesses tired of ramsomware and other malware finally connect 70% of security incidents with the language of memory corruption and finally ask their providers &quot;Wait, what language did you code this in?&quot;, then it won&#x27;t be up for programmers themselves to decide. Money will talk. Very few programmers get to decide what language is used in $DAYJOB.<br> <p> BTW Rust is of course not the only memory safe language and this &quot;no memory corruption&quot; trend has started already, after all Java/Kotlin, Javascript, Swift and golang are already very popular. What&#x27;s new with Rust is filling the last gap where C and C++ had no serious competition. That&#x27;s why its zealots feel threatened.<br> <p> </div> Sat, 17 Jul 2021 20:52:26 +0000 Ownership and lifetimes https://lwn.net/Articles/863275/ https://lwn.net/Articles/863275/ mrugiero <div class="FormattedComment"> Then you use an older system I guess. If you were fine with no updating your software you&#x27;re probably fine with that too.<br> </div> Sat, 17 Jul 2021 16:06:25 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863238/ https://lwn.net/Articles/863238/ marcH <div class="FormattedComment"> Exactly. <br> <p> C++ is safe, you&#x27;re just &quot;holding it wrong&quot;. Well, too bad a couple lines of code &quot;held wrong&quot; are enough for a vulnerability or elusive concurrency crash.<br> <p> Standard committee-level discussions matter, but how that translates into what happens in the trenches matters even more.<br> <p> </div> Fri, 16 Jul 2021 22:30:19 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863111/ https://lwn.net/Articles/863111/ roc <div class="FormattedComment"> Python is a mess.<br> <p> Rust libraries that wrap a C library usually come with a &quot;build script&quot; (build.rs) that is capable of downloading, configuring, building and linking the C library. This works very well in practice, and is not a hack at all. The cc library (<a href="https://crates.io/crates/cc">https://crates.io/crates/cc</a>) gives you a nice API to help with this. A lot of these Rust libraries also give you the option of using the system version of the library if you want.<br> <p> If the C code itself has dependencies that aren&#x27;t available on the system then that would get complicated. I haven&#x27;t encountered this problem in my Rust work. If I did, I guess I&#x27;d probably choose a different library.<br> <p> <font class="QuotedText">&gt; suddenly the distro system library/dependency model doesn&#x27;t look so bad after all.</font><br> <p> No, the model where distros package all libraries simply doesn&#x27;t work at all for me, and lots of other developers, for the reasons I mentioned.<br> </div> Fri, 16 Jul 2021 00:20:16 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863107/ https://lwn.net/Articles/863107/ pizza <div class="FormattedComment"> <font class="QuotedText">&gt; When I&#x27;m writing software I&#x27;ll decide what libraries and what versions of libraries I want to depend on. I&#x27;m not going to ask the Ubuntu maintainers to decide which libraries are OK for my project.</font><br> <p> Sure, you need pyFoo == 1.33.1 (or whatever)<br> <p> Meanwhile, pyFoo includes a big pile of native C (or Rust, or whatever) code that itself has other dependencies.<br> <p> How are those dependencies and sub-dependencies handled? (The answer: Quite badly, as in &quot;It only works on a specific Ubuntu point release.&quot; Go ahead, ask me how I know this)<br> <p> These language-specific repositories are great, until they inevitably have to reach outside the language ecosystem. Then it&#x27;s hack upon hack until suddenly the distro system library/dependency model doesn&#x27;t look so bad after all.<br> </div> Thu, 15 Jul 2021 23:46:12 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863102/ https://lwn.net/Articles/863102/ mss <div class="FormattedComment"> For many people it&#x27;s far easier to trust (and occasionally randomly verify) just one distro package repository rather than the distro one plus all the programming-language-related ones.<br> Especially that there were already some backdoored packages found in, for example, NPM and PyPI, so the threat is very real.<br> <p> <font class="QuotedText">&gt; When I&#x27;m writing software I&#x27;ll decide what libraries and what versions of libraries I want to depend on.</font><br> <p> Distros sometimes (often?) need to build and run a package against different library versions than its upstream supports (for various reasons).<br> <p> </div> Thu, 15 Jul 2021 23:14:20 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863044/ https://lwn.net/Articles/863044/ rgmoore <blockquote>C++ can express abstractions that Rust (still) cannot.</blockquote> <p>This is trivially true, since one of the goals of Rust is to make it difficult or impossible to express some kinds of bugs. Greater expressivity is desirable only to the extent the things you're expressing are themselves desirable. Adding lots of foot guns makes the language more expressive, but in a way that's likely to make the final output worse rather than better. Thu, 15 Jul 2021 17:11:12 +0000 Ownership and lifetimes https://lwn.net/Articles/863039/ https://lwn.net/Articles/863039/ khim <p>This is all well and good, but this requires some form of <b>consensus</b>.</p> <p>And in C/C++ world discussions are just <b>not happening</b>. Why have the coveted “pointer provenance” proposals were not incorporated into standard in 15 years (and counting)?</p> <p>Because not even C/C++ compiler writers can agree with each other. <a href="https://blog.regehr.org/archives/1180">-std=friendly-c</a> proposal <a href="https://blog.regehr.org/archives/1287">had the exact some fate</a>.</p> <p>And when someone tries to resolve the issue by “starting from scratch”… the end result is D, Java, C# or Rust… <b>never</b> a “friendly C”…</p> <p>Rust is just the first such “new C” language which is low-level enough to actually be usable for <b>all</b> kinds of usages. Starting from lowest-level just above assembler.</p> Thu, 15 Jul 2021 16:42:55 +0000 Ownership and lifetimes https://lwn.net/Articles/863015/ https://lwn.net/Articles/863015/ farnz <p>If such platforms exist and need to be cared about (like you, I'm not sure if they did, or did not), an easy solution would be to make the behaviour of signed integer overflow unspecified, rather than undefined. <p>In the C language spec, there are four groups of behaviour (from strongest definition to weakest): <ol> <li>Defined. To be a confirming implementation, you must behave in the way the Standard says you should, and there are no choices here. For example, the behaviour of the <tt>free(void * ptr)</tt> standard library function in C is defined if <tt>ptr</tt> is <tt>NULL</tt> or a pointer returned by <tt>malloc</tt>. <li>Implementation defined. The Standard sets out restrictions on what this can be defined as, but the implementation gets to choose one concrete behaviour and stick to it. For example, the number of bits in <tt>int</tt> is implementation defined in C - any value greater than or equal to 16 is permissible, and the implementation must document which value it has cchosen. <li>Unspecified. The Standard sets out restrictions on what behaviour is acceptable (e.g. <tt>"abc" == "abc"</tt> must be either 1 for true or 0 for false depending on whether the compiler merges identical string literals, but it cannot be 42 under any circumstances). The compiler can choose any behaviour it likes from the set the standard allows, and can choose different behaviour every time it sees the unspecified construct (e.g. <tt>printf("%d %d\n", "abc" == "abc", "abc" == "abc");</tt> can print "0 0", "0 1", "1 0", or "1 1", and can print a different one each time the program is run); it does not have to stick to one choice, as it does for implementation-defined behaviour. <li>Undefined. If a program run would follow a path with undefined behaviour, the meaning of the program as a whole is not set out by the Standard; it can do anything the compiler implementer wishes, even if the user of the compiler thinks that's a crazy stupid outcome. </ol> <p>If signed integer overflow became unspecified, such that the result of a signed integer overflow could be any integer value, then we're in a much better place. The compiler can just use the machine instruction (assuming it doesn't trap), and we don't have the pain where the compiler goes "well, if this is signed overflow, then behaviour is undefined, ergo I can assume it's not, ergo I can optimise out a check"; instead, signed overflow has to produce an integer, but which integer is not known by the code author. Thu, 15 Jul 2021 16:26:19 +0000 Ownership and lifetimes https://lwn.net/Articles/863032/ https://lwn.net/Articles/863032/ matthias <div class="FormattedComment"> Even if there is a platform that lacks an overflow happens flag. Then on this platform the implementation defined behavior is overflow with the semantics of what overflow means on this platform. Implementation defined means you can choose different semantics for very combination of compiler/platform. <br> <p> If you do not know which platform your code will run on, you can still be not sure what the result of x+100 is in case of overflow, but you can at least be sure what (x+100)&amp;0 is. And you can be sure that if you do an assertion x+100&gt;x to test for an overflow that the assertion is not optimized away. Ok, it can be optimized away of the compiler can prove that there is not overflow, but this is no problem.<br> </div> Thu, 15 Jul 2021 15:56:18 +0000 Ownership and lifetimes https://lwn.net/Articles/863007/ https://lwn.net/Articles/863007/ mathstuf <div class="FormattedComment"> <font class="QuotedText">&gt; That is, if it&#x27;s implementation defined the compiler you use needs to define a given behavior for the platform it&#x27;ll run and never violate it. So, gcc would be mandated to tell you what value will result from overflowing, even if such a value is one for SPARC and a different one for x86. I fail to see why it UB made more sense to them than that at the time.</font><br> <p> I may be misremembering, but didn&#x27;t some platforms not provide a way to tell? That would require the compiler to emit manual checks for every possible overflowing operation in order to guarantee *a* behavior. This would also mean that optimizing to, e.g., FMA instructions is basically impossible because if the intermediate ops overflow, that needs to be handled as well.<br> <p> But if there are no platforms that lack an &quot;overflow happened&quot; flag…meh.<br> </div> Thu, 15 Jul 2021 14:12:19 +0000 Ownership and lifetimes https://lwn.net/Articles/863004/ https://lwn.net/Articles/863004/ mathstuf <div class="FormattedComment"> Well, the fun thing here is that the problem appeared on macOS arm64. Previously, everything had been working on all platforms (our library does use `-fvisibility=hidden` to emulate Windows behavior on the other platforms because we *do* export our symbols properly). Which makes me wonder why the typeinfo wasn&#x27;t already duplicated…but whatever. Anyways, something is different with macOS arm64 and this problem came up and now it&#x27;s fixed by improving the code, so I&#x27;m happy at least (and it&#x27;s one more &quot;ghostly linker fun&quot; bug under my belt :/ ).<br> </div> Thu, 15 Jul 2021 13:46:43 +0000 Ownership and lifetimes https://lwn.net/Articles/863003/ https://lwn.net/Articles/863003/ mathstuf <div class="FormattedComment"> These snipe-y comments sound awfully embarrassing by themselves to me too. If the post is so embarrassing, why not just leave them to stand on their own if you&#x27;re not going to contribute anything to the discussion in your reply?<br> </div> Thu, 15 Jul 2021 13:43:57 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/863002/ https://lwn.net/Articles/863002/ mathstuf <div class="FormattedComment"> <font class="QuotedText">&gt; C++ can express abstractions that Rust (still) cannot.</font><br> <p> The one I know of is &quot;template template&quot; parameters (basically higher kinded types). I suspect concepts can get one higher-ranked trait bounds as well, but I&#x27;m not sure about that. FWIW, both of these are being worked on.<br> <p> On the other hand, C++ lacks useful destructuring (pattern matching is being worked on, but I don&#x27;t see it being anywhere near as ergonomic), is stuck with terrible macro expansion rules, bad move semantics, and a blissful unawareness of lifetime analysis at the language (as opposed to the documentation/review) level.<br> <p> I know which set *I* find more useful, but that&#x27;s obviously not all that universal since there are many niches in the programming space.<br> </div> Thu, 15 Jul 2021 13:42:15 +0000 Ownership and lifetimes https://lwn.net/Articles/862949/ https://lwn.net/Articles/862949/ foom <div class="FormattedComment"> The problem you describe here is that windows (PE/COFF) DLLs don&#x27;t support C++&#x27;s vague linkage symbols across DLLs properly. This makes windows DLLs effectively incompatible with the C++ standard&#x27;s requirements.<br> <p> Neither MacOS (mach-o) nor Linux (elf) shared libraries have this issue. They both work fine in this situation, by ensuring that vague linkage symbols are exported and deduplicated across the shared library boundaries by default.<br> <p> One might expect this would have been addressed in Windows at some point in the last few decades...but it hasn&#x27;t been.<br> </div> Thu, 15 Jul 2021 11:49:27 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/862927/ https://lwn.net/Articles/862927/ roc <div class="FormattedComment"> If you&#x27;re going to contradict a C++ standards committee member when making a claim about the capabilities of C++, you&#x27;d better have some evidence to back it up. So, how do you achieve equivalence to Rust memory and thread safety with C++? (Don&#x27;t say ASAN or TSAN, because those tell you nothing about untested paths.)<br> </div> Thu, 15 Jul 2021 06:21:37 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/862926/ https://lwn.net/Articles/862926/ roc <div class="FormattedComment"> Rust &quot;cargo&quot; definitely is not trying to &quot;reimplement the distro package repository&quot;. Distro-packaged libraries come nowhere near cargo&#x27;s capabilities --- e.g. feature selection, library version selection, the ability to substitute patched versions of libraries, the ability to run multiple versions side by side, the ability to publish libraries whenever you want and use them in any project immediately regardless of what Linux distro your users are running --- or, of course, if they&#x27;re not running Linux at all.<br> <p> When I&#x27;m writing software I&#x27;ll decide what libraries and what versions of libraries I want to depend on. I&#x27;m not going to ask the Ubuntu maintainers to decide which libraries are OK for my project.<br> </div> Thu, 15 Jul 2021 06:10:34 +0000 Ownership and lifetimes https://lwn.net/Articles/862925/ https://lwn.net/Articles/862925/ ncm <div class="FormattedComment"> You have failed to keep up with events, so you embarrass yourself by publishing falsehoods.<br> </div> Thu, 15 Jul 2021 05:52:40 +0000 Announcing Arti, a pure-Rust Tor implementation (Tor blog) https://lwn.net/Articles/862924/ https://lwn.net/Articles/862924/ ncm <div class="FormattedComment"> Yet, you can. The propaganda machine loves an underdog, but the great bulk of real work, by several orders of magnitude, is still done in C++, and will be for a long time to come.<br> <p> C++ can express abstractions that Rust (still) cannot. But both languages are evolving rapidly.<br> </div> Thu, 15 Jul 2021 05:41:39 +0000 Ownership and lifetimes https://lwn.net/Articles/862919/ https://lwn.net/Articles/862919/ mrugiero <div class="FormattedComment"> I find your post very educational, however, it doesn&#x27;t address my point: all the problems in making signed integer overflow defined behavior could have been fixed by making it implementation defined rather than undefined. Implementation defined means it&#x27;s still hard to write *portable* code, but that when you do know where it&#x27;ll run, you know there exists one behavior that is appropriate. That is, if it&#x27;s implementation defined the compiler you use needs to define a given behavior for the platform it&#x27;ll run and never violate it. So, gcc would be mandated to tell you what value will result from overflowing, even if such a value is one for SPARC and a different one for x86. I fail to see why it UB made more sense to them than that at the time.<br> <p> But yeah, talking about artificial puzzles when you have all those kinds of behavior and you don&#x27;t even mandate warnings when you hit them is a bit hypocritical.<br> </div> Thu, 15 Jul 2021 02:16:47 +0000 Ownership and lifetimes https://lwn.net/Articles/862917/ https://lwn.net/Articles/862917/ mrugiero <div class="FormattedComment"> Stupidly enough, I didn&#x27;t think of references. It shows how much time passed since the last time I wrote C++ :)<br> </div> Thu, 15 Jul 2021 02:10:08 +0000