The conversation

Lessons learnedExperience excerpt · English

Oh, if only that worked in practice

Oh, if only that worked in practice. There's far too much use of "unsafe" in Rust crates. Sometimes, for really good reasons. Too often, because someone can't figure out a safe way to do something. Here's a thread I started on Reddit on this subject: "We're not really game yet".[1] Someone commented there: "There are people here who would volunteer to help you out, dig up the internals and address those issues, given you provide them with sufficient information." My reply: I've done that three times now: * jpeg2000-decoder -- JPEG 2000 decoder test fixture. This exercises jpeg2k->jpeg2000-sys->OpenJPEG. The first two are in Rust, the last one is in C, and valgrind shows it referencing un-initialized memory. It randomly segfaults. OpenJPEG has a long history of doing this, and has been the subject of several CERT security advisories. The author of jpeg2k has managed to contain the the problem by running OpenJPEG in a WASM sandbox. This keeps the program from crashing, but there is a 2.6x performance penalty. …

Original discussionSafety and Soundness in Rust90 source comments · at import
5

Community replies 0

No community replies yet. Add your perspective.

Replies from the source 5

Direct replies available in this import. Original-language excerpts.

YG

> This is why no one has successfully done a major game on Rust. The foundations are too weak to support it. That's patently false. https://veloren.net/ People have made games in it. And in Zig, and C, and C++ and so. And assembly. And machine code. Unsafety isn't a problem it's lack of libs and integration. If you refer to AAA the issue is lack of engines where Rust is a must. I.e. network effect, you need engines in Rust to make games in Rust. And to make engines in Rust, more games need to require Rust.

Full original
OL

> This is why no one has successfully done a major game on Rust. The foundations are too weak to support it. The Finals open beta is happening on the 6th. Check it out https://www.reachthefinals.com/ Here is a blog post about their usage of Rust: https://medium.com/embarkstudios/inside-rust-at-embark-b82c0...

Full original
NI

I might have misunderstood what you've written, but is there a reason you can't use https://github.com/etemesi254/zune-image as a JPEG decoder? It has minimal use of unsafe and is performant.

Full original
VV

I don't want to trivialize anything but I most of my time in gamedev was dealing with similar either engine uplevel-integration hell(the team I was on still has scars from having to rebaseline UE3 on a 3 month cadence which took... 3 months every time we did it so it was back-to-back uplevels) or dealing with these sorts of things even in established engines. Yes Unity does better but there's a ton of momentum with established commercial engines that have tens of millions of dollars invested in them. It was only recently that Godot has started making some inroads on the indie side of the engine space.

Full original
DJ

Your story points out the unfortunate corollary of the OP's point. He states that if there is unsafe code that is called, it's never the caller's fault. Conversely, it means the caller can't do anything about it, and must wait for an upstream fix.

Full original
Continue on Hacker News

Respect different perspectives. Share concrete experiences.

Sign in to post, reply, repost, and quote.