frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Rust Devs Think We're Hopeless; Let's Prove Them Wrong (With C++ Memory Leaks)

https://www.babaei.net/blog/rust-devs-think-we-are-hopeless-lets-prove-them-wrong-with-cpp-memory-leaks/
25•zdw•22h ago

Comments

eptcyka•22h ago
Memory leaks are by far the least interesting class of defect that Rust helps with - leaking memory is safe.
genter•22h ago
Until the kernel kills you for being OOM.
YZF•22h ago
That's still safe.

EDIT: Safe in the sense you're not writing into memory you don't own, e.g. write after release, buffer overflows etc.

scotty79•21h ago
Program that no longer runs is the safest.
aquariusDue•21h ago
For true safety we must prevent it from being written in the first place /s
dmit•21h ago
That's the true meaning of backward compatibility. The [backward] refers to the time scale.
drivingmenuts•21h ago
stomps butterfly

I've just saved untold generations from certain calamity.

** 6,000,000 years later **

Butterfly King: This chimpanzee-descended motherfucker ….

airstrike•21h ago
I'll add that even safety itself is not the sole reason why some people prefer Rust. There's a lot to Rust besides that and sometimes it's not about memory safety as much as it is about steering you into patterns Rust devs perceive as better overall.
jayd16•21h ago
Possible attack vector, though.
andrewflnr•21h ago
The least interesting attack vector. You can fix it by rebooting.
Arnavion•21h ago
And in fact is not even something that Rust does differently from C++. Memory releases in Rust are handled by dtors just like they are in C++. What a weird article.

(The only difference is that Rust defaults to moving while C++ defaults to copying, and Rust moves don't leave a moved-out object behind while C++ does, so the dtors in Rust are simpler and called fewer times than the equivalent C++ code.)

dmit•21h ago
Yes, the only difference.
api•21h ago
The problem with unsafe languages is not that you can’t write safe code in them with skill and discipline.

The problem is that programmers don’t always do that, either because they are not that experienced or they are in a hurry.

The real danger is when code is long lived and worked on by multiple people. One bad commit after a late night hacking session and now there is a zero day just waiting to be discovered.

Safe languages don’t rule that out but they make it profoundly less likely.

bluGill•21h ago
I write C++ all the time and I still cannot convince many developers to use unique_ptr over new. It isn't that hard to write code that doesn't leak but if you bypass the language features it cannot help you.

for that matter though I've seen rust programmers put everything in unsafe.

on_the_train•21h ago
There's static analysis which can effectively force these things. C++ problems are self-inflicted
bluGill•15h ago
There is but we have code predating c++11 that isn't worth rewriting. So the static analisys is off. We do use lots of static analisys but that one is too hard to fix all the old code that we have decades of proff works and isn't leaking (much?)
andrewflnr•21h ago
I mean, a sufficiently safe language would rule it out. Either one not expressive enough to express memory unsafety (i.e. GC or fully linear types with no escape hatches) or one that requires a machine checked proof of safety to compile. These options just happen to be too big of a pain in the assembly for today's appetite.
api•4h ago
There are lots of languages where true memory bugs are impossible. As you say they are higher level and usually GC.
shmerl•21h ago
No, C++ is hopeless. No need to bend over backwards to try to disprove it. It's not only about memory safety, some of it is about legacy stuff and backwards compatibility it's forever stuck with.
tom_•21h ago
This only works with the VC++ CRT, which is potentially a bit limiting!

Also, the DEBUG_NEW thing is useless in practice since, from memory, it stops you using placement new, and dependencies typically don't participate, so a zillion unlabeled leaks is the usual result from the common case of you failing to call some dependency's free function.

And the allocation IDs (and therefore _CrtSetBreakAlloc) are pretty worthless in practice for multithreaded programs, because the allocation order isn't deterministic.

I use the LEAK_CHECK_DF flag in the programs I write (and the CHECK_ALWAYS_DF is worth investigating too), but the only point is to indicate whether there are leaks on exit, yes/no. If no, great; if yes, well that's useful information, but the actual output is almost never helpful. (Though occasionally I do somehow introduce a leak from something that happens before the first thread is created.)

yusina•21h ago
It's 2025 and we are still discussing memory leaks. The very existence of this article is an indication that C++ (used like that) has an issue. Non-kernel programmers should not even be able to create memory leaks by mistake.

Well, unless they are doing something incredibly stupid including stepping over several explicit warnings of "don't do this unless you are very sure about what you are doing".

teleforce•15h ago
It's really a shame isn't it? It's 2025 and we still have no programming languages that have impeccable GC for automatic memory management rather than forcing programmer to wrestling and fighting for manually managing the memory [1].

Auto industry kind of solved this automation mechanism for example with the new high performance Toyota GR Corolla has a new automatic gear transmission that's proven as fast if not faster than the manual version [2]. The same goes to F1, the epitome of car racing performance.

[1] Understanding Memory Management, Part 5: Fighting with Rust (101 comments):

https://news.ycombinator.com/item?id=43882291

[2] 2025 Toyota GR Corolla's New Automatic Gearbox Democratizes Fun:

https://www.caranddriver.com/reviews/a62672128/2025-toyota-g...

linotype•20h ago
I’ve seen way more comments from C++ developers complaining about Rust developers insulting them than I’ve seen Rust developers actually insulting C++. It’s weird to see how attached people are to programming languages, though it’s weird to me too how attached people are to ICE/drivetrains.
sunrunner•20h ago
I think that's because the Rust developers are having too much fun sitting on their high horse shouting about how great the horse is to need to spend time yelling about the people _not_ on the horse, while the C++ developers don't have a horse to yell about so need one to yell _at_ instead.
squirrellous•15h ago
It’s about jobs and livelihoods, even if not everyone will admit it. It’s easy to emotional when the argument boils down to “your skills are now outdated, go learn a better one”.
fithisux•19h ago
c++ is a huge language, with lots of backwards compatibility.

I think c++ should keep the good modern things and fork (restart) from there by breaking backwards compatibility, c++23 will be frozen with some fixes.

Create a new type of PKM for everyone

https://www.vetis.ai/
1•AiVetis•2m ago•0 comments

Several conferences relocate north of the border as Canadians refuse U.S. travel

https://www.cbc.ca/lite/story/1.7531255
1•colinprince•3m ago•0 comments

We built C1 – an OpenAI-compatible LLM API that renders real UI instead of md

1•rabisg•5m ago•0 comments

Linux Kernel Exploitation Series

https://r1ru.github.io/categories/linux-kernel-exploitation/
1•hkopp•8m ago•0 comments

Rescission of Recordkeeping on Restricted Pesticides by Certified Applications

https://www.federalregister.gov/documents/2025/05/12/2025-08220/rescission-of-recordkeeping-on-restricted-use-pesticides-by-certified-applications
1•impish9208•9m ago•0 comments

Byte Latent Transformer: Patches Scale Better Than Tokens

https://arxiv.org/abs/2412.09871
1•dlojudice•11m ago•1 comments

Hacker News Dark Mode (Chrome Extension)

https://chromewebstore.google.com/detail/hacker-news-dark-mode/jnmbfobflanbemhhphppnjmfhhfdkegd
1•michalpleban•12m ago•0 comments

The USA's First Pope

https://www.amazingfacts.org/media-library/first-usa-pope
1•afaxwebgirl•12m ago•1 comments

Show HN: UsePRD-Plan new features with full codebase context- drop into Cursor

https://useprd.com
1•hotrod46•14m ago•1 comments

A new type of AI is helping police skirt facial recognition bans

https://www.technologyreview.com/2025/05/12/1116295/how-a-new-type-of-ai-is-helping-police-skirt-facial-recognition-bans/
1•gnabgib•15m ago•0 comments

Combine Hash and Limited Preimage Data to Improve Security of Password Hash

https://github.com/OWASP/www-community/issues/901
1•Edmond•15m ago•0 comments

Why Magician David Blaine Fasts for Days Before His Shows

https://www.wsj.com/style/david-blaine-stunt-magic-national-geographic-do-not-attempt-c5c48582
1•elsewhen•17m ago•0 comments

Ask HN: Can On-device AI solve projected energy crisis?

1•vkkhare•19m ago•1 comments

Fingers wrinkle in the same pattern every time

https://www.binghamton.edu/news/story/5547/do-your-fingers-wrinkle-the-same-way-every-time-youre-in-the-water-too-long-new-research-says-yes
1•geox•23m ago•0 comments

Perplexity wrapping talks to raise $500M at $14B valuation

https://www.cnbc.com/2025/05/12/perplexity-funding-round-comet.html
1•mfiguiere•26m ago•1 comments

If Everyone Has Trauma, Everyone Has Trauma

https://freddiedeboer.substack.com/p/if-everyone-has-trauma-everyone-has
2•paulpauper•28m ago•0 comments

I hacked a dating app (and how not to treat a security researcher)

https://alexschapiro.com/blog/security/vulnerability/2025/04/21/startups-need-to-take-security-seriously
42•bearsyankees•28m ago•8 comments

At least five interesting things: Requiem for capitalism edition (#63)

https://www.noahpinion.blog/p/at-least-five-interesting-things-b5d
1•paulpauper•28m ago•0 comments

Show HN: Shorts Stopper – Block YouTube Shorts on Safari iOS

https://apps.apple.com/us/app/shorts-stopper/id6745517488
1•abyesilyurt•29m ago•0 comments

We built AI-powered Root Cause Analysis that works

https://coroot.com/blog/we-built-ai-powered-root-cause-analysis-that-actually-works/
2•ekiauhce•30m ago•0 comments

Microsoft shares rare look at Windows 11 Start menu designs it explored

https://www.windowscentral.com/software-apps/windows-11/microsoft-shares-rare-look-at-radical-windows-11-start-menu-designs-it-explored-before-settling-on-the-least-interesting-one-of-the-bunch
1•taubek•30m ago•1 comments

How the Net Was Won – University of Michigan Heritage Project

https://heritage.umich.edu/stories/how-the-net-was-won/
1•rbanffy•30m ago•0 comments

The Internet 1997 – 2021

https://www.opte.org/the-internet
2•smusamashah•31m ago•0 comments

Ex-UK Special Forces break silence on 'war crimes' by colleagues

https://www.bbc.com/news/articles/cj3j5gxgz0do
23•tartoran•33m ago•2 comments

Spall: A code profiler that runs in the browser

https://gravitymoth.com/spall/spall-web.html
2•surprisetalk•33m ago•0 comments

Why So Many in Gen Z Are Choosing the Creator Economy over Degrees in India

https://www.outlookbusiness.com/magazine/gen-z-is-ghosting-degrees-and-day-jobs-to-go-all-in-on-the-creator-economy-in-india
1•yarapavan•35m ago•0 comments

Show HN: I built a system to make ChatGPT brutally honest with you

https://www.honestprompts.com/
1•moobuilds•35m ago•0 comments

RIP Usenix ATC

https://bcantrill.dtrace.org/2025/05/11/rip-usenix-atc/
8•joecobb•38m ago•0 comments

Google Worried It Couldn't Control How Israel Uses Project Nimbus, Files Reveal

https://theintercept.com/2025/05/12/google-nimbus-israel-military-ai-human-rights/
8•jaredwiener•38m ago•1 comments

The Formula for Business Success

https://sekniqi.com/business-formula/
1•sekniqi•39m ago•0 comments