r/ProgrammerHumor • • Oct 22 '26

instanceof Trend itsBadIfItsOnlyPHP

Post image
4.5k Upvotes

335 comments sorted by

View all comments

Show parent comment

44

u/Usual_Office_1740 Oct 22 '26 edited Oct 22 '26

Don't look at the 11 year old high priority borrow checker error that came out today that allows for UB in safe Rust.

I saw your /s and thought it was funny. My response is real.

Edit: I learned about it today. Someone else pointed out that it might be older.

40

u/Ok-Scheme-913 Oct 22 '26

I mean, compiler bugs... exist. They are not particularly easy to hit and especially hard to exploit though.

Many type systems also have unsoundness bugs, you just have to write the code in a very special unnatural way, so they don't really ever come up in real code.

I believe this borrow checker one was the same case.

(And Im no rust fanboy, see my other comments where I'm sarcastically say that rust just never got popular enough to have this kind of vuln)

10

u/Usual_Office_1740 Oct 22 '26

You are right and I was more poking fun than anything. It was just relevant in my mind because I'd just watched the LetsGetRusty YouTube video of it. This one was extremely obscure and requires a custom impl of a trait that is auto generated for you.

I think that compilers have very few bugs compared to their complexity level and the developers that write them do phenomenal work.

2

u/throwaway490215 Oct 23 '26

Which is why i cant wrap my head around the people defending PHP.

Its not about Rust being perfect. Its about any big exploit the Rust community the rust-focused social media channels would be filled with analysis on how the safety features failed.

All i'm seeing from PHP is deflection about how other langs also sometimes get exploited. Sorry but that logic is bad and overlooking the important bits: how PHP can't properly secure their 1 big blob of unsafe C that parses every HTTP request, and is unwilling to talk about it or how their average dev doesn't seem to realize how far behind mainstream security practices they are.

63

u/SelfDistinction Oct 22 '26

Don't forget about the double reference lifetime bug that is still open after a decade.

That being said "the compiler might not catch a possible segfault if you write absolutely horrendous spaghetti" is not exactly on the same level as "actively exploited RCE because you didn't correctly free a buffer and use global state for request data in a webserver."

10

u/GegeAkutamiOfficial Oct 22 '26

My response is real.

C++

Dude, that's just a regular Tuesday in C++...

https://2025.splashcon.org/details/OOPSLA/111/Fuzzing-C-Compilers-via-Type-Driven-Mutation?utm_source=chatgpt.com

https://arxiv.org/html/2508.18955v1

Especially since almost all UB bugs are just transferred to the user instead, and good luck catching them all.

https://eel.is/c++draft/ub?utm_source=chatgpt.com

... idk, by next year the rust compiler will fix the already obscure bug, but the C++ UB will remain UB. As someone that pays his bills with C++, I don't see it as a win.

3

u/Usual_Office_1740 Oct 22 '26

Agreed. I like C++. I may even prefer it to Rust. I think the committee made a bad decision when they discontinued P3390. Sean Baxter was on the right track and profiles don't seem to solve the crux of the problem once you get away from simple examples.

5

u/skywalker-1729 Oct 22 '26

If this is the same one, I saw it a few weeks ago and I believe it wasn't really a bigger security issue.

0

u/Usual_Office_1740 Oct 22 '26 edited Oct 22 '26

It might be. It seemed pretty niche. You needed a couple of static lifetime values and a custom drop impl.

6

u/shrodikan Oct 22 '26

UB = Unsafe Borrowing? Is that basically a use-after-free Rust edition?

18

u/-nerdrage- Oct 22 '26

Universes Beyond, it is when other franchises enter yours like in magic the gathering.

4

u/Usual_Office_1740 Oct 22 '26

This is legitimately annoying to me as both a Commander player and a C++ programmer. Don't forget it's also blue black.

14

u/Usual_Office_1740 Oct 22 '26

UB means undefined behavior. In safe Rust the borrow checker guarantees there is no UB. Or at least that's the idea. It rejects some technically valid code in favor of guaranteeing that a sub set of complex code is safe.

A simple example is array like collection access. If you use [] in C++ to access out of bounds of a collection, you have UB. If you access out of bounds you could get garbage data or you might get a segfault. The compiler might assume the pointer the array access decays to is valid and make optimization decisions based on that because the compiler always assumes the programmer has not written UB code.

In safe Rust all array access is bounds checked. The compiler and the array safe api guarantees that you only access within bounds, always. It is not possible in safe Rust to write UB code using any of the array like collections.

26

u/darrenturn90 Oct 22 '26

Undefined behaviour

3

u/Cronos993 Oct 22 '26

Undefined Behavior

3

u/sirreldar Oct 22 '26

Undefined behavior

0

u/redlaWw Oct 22 '26

Strictly speaking, those aren't undefined behaviour - the behaviour is defined but the compiler is wrong.