5 ms·
Which bugs? I wasn't under the impression that exploiting memory safety issues was the dominant type of bug to gain an advantage in multiplayer games, but usual
by spijdar 6y ago
Which bugs? I wasn't under the impression that exploiting memory safety issues was the dominant type of bug to gain an advantage in multiplayer games, but usually logic errors or some kind of broken script, corner cases in nested control structures, that sort of thing.
I can see an argument that Rust could also help prevent those as it is a higher-level language and has a few language features to prevent some of the logic problems, but not that many?
- Kye 6y agoMy knowledge is many years out of date, so I might be wrong.
- spijdar 6y agoI'm also not really that familiar with either Rust or modern multiplayer games, I'm just speculating. It seems like if you could buffer-overflow the server, there are more sinister things you could do besides game-the-game... (that said, I have personally found bugs in text-based MUDs that could have been prevented by Rust. They were all "just" DoS bugs though, instantly crash the server type things)
- gpm 6y agoHonestly, I think rust actually prevents a lot of logic problems, but it's hard to quantify and a subjective feeling that I'm not sure how I'd even go about trying to "prove". Order of magnitude I'd say 50% less logic bugs than a language like Java. Why? Just good language design. Things like "enums" (algebraic data types, not C-enums) making for type checked state machines, really strict typing, immutability by default, simple language semantics, good linters that people actually use, the borrow checker actually does usually lend itself to good design too, and so on.
- zesterer 6y agoIt's a mixed bag. Short of defining a formal spec and writing the program with a theorem prover, "bug-free" code isn't really a realistic goal. However, Rust does come with tools that at the very least allow the building of APIs that are very difficult to abuse via the trait system and other features such as sum types. Ultimately, spaghetti code is possible in virtually any language, so keeping a good eye on architecture is necessary no matter the language. What I would say is that Rust makes it easier to keep architecture constrained and correct.
- hctaw 6y agoThere are memory safety bugs that won't cause a segmentation fault or create a buffer overflow exploit, but result in logical errors. For example: void inner (const T& t1, T& t2); void outer (T* t, int i, int j) { inner(t[i], t[j]); } There are three memory safety bugs in that code: - the pointer `t` is not checked for null - the indices `i` and `j` are not checked to see if they are outside the bounds of `i` and `j` - the indices `i` and `j` are not checked to see if they are the same. The first bug will cause a segfault and crash. The second is a potential buffer exploit. The third is a logical bug that can be exploited depending on what inner() is supposed to do. Most people know to check the first two, the third one is subtle and isn't necessarily a bug. But it may become a bug that can be exploited inside `inner`, especially over the lifetime of the code. Rust will prevent all three, or force you to perform the checks before using an `unsafe` block. But more than that, this kind of issue crops up due to an inherent weakness of code review - it catches errors in blocks of logic, but not in logic below it and logic above it. Since C/C++ don't have idiomatic error handling worth a damn (the only "idiomatic" errors in C++ are debug assertions, ime) you can't defend against silent logic bugs due to violating invariants of callers or callees that are expressed through Option/Result types in Rust (I mentioned this in a comment above). That's the real benefit of writing code in Rust, in addition to the absence of footguns.
- zesterer 6y ago> The first bug will cause a segfault and crash. Or, you know, nasal demons
- astrobe_ 6y agoIt is sad to see that sibling answers are somewhat avoiding the question. I concur, "exploits" in MMORPG are about abusing unintended consequences in the design of the world, not in the design of the program. Like spawn locations where mobs are trapped and easier to kill, or combinations of weapons/gears/abilities that give an unforeseen advantage. That a stronger type system "eliminates a whole class of bugs" is nice and all, but users should be wary of the false sense of security it gives (in the same way that the weak type system of C gives a false sense of security when you come from assembler programming). You can have proven and certified bug-free crypto routines, and fail pathetically because their a giant hole in your crypto system. Just a friendly warning.