News for hackers. Stuff that matters.
Re:Veloren – Open-source MMORPG written in Rust by Kye on Friday February 05, 2021 @11:48AM (#26038285)
The #1 problem in MMORPGs is people exploiting bugs for personal gain at the expense of the game's economy and competitiveness in PvP. Some of those bugs end up being in NPC scripts, but most are the kind Rust helps prevent.
Re:Veloren – Open-source MMORPG written in Rust by spijdar on Friday February 05, 2021 @11:58AM (#26038418)
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?

Re:Veloren – Open-source MMORPG written in Rust by gpm on Friday February 05, 2021 @12:51PM (#26039097)
Honestly, 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.

Re:Veloren – Open-source MMORPG written in Rust by bcrosby95 on Friday February 05, 2021 @01:33PM (#26039631)
Why must you trigger my inability to stick to a programming language? Elixir, Clojure, or Rust - round-a-round in my head they go. Will it ever stop, hell if I know. sigh
Re:Veloren – Open-source MMORPG written in Rust by zesterer on Friday February 05, 2021 @01:09PM (#26039331)
This is a good summary tbh
Re:Veloren – Open-source MMORPG written in Rust by hctaw on Friday February 05, 2021 @01:46PM (#26039761)
There 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.

Re:Veloren – Open-source MMORPG written in Rust by zesterer on Friday February 05, 2021 @02:01PM (#26039912)
> The first bug will cause a segfault and crash.

Or, you know, nasal demons

Re:Veloren – Open-source MMORPG written in Rust by zesterer on Friday February 05, 2021 @01:08PM (#26039320)
It'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.
Re:Veloren – Open-source MMORPG written in Rust by astrobe_ on Saturday February 06, 2021 @02:39AM (#26044883)
It 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.

Re:Veloren – Open-source MMORPG written in Rust by Kye on Friday February 05, 2021 @12:02PM (#26038463)
My knowledge is many years out of date, so I might be wrong.
Re:Veloren – Open-source MMORPG written in Rust by spijdar on Friday February 05, 2021 @12:06PM (#26038509)
I'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)

Re:Veloren – Open-source MMORPG written in Rust by Thaxll on Friday February 05, 2021 @12:12PM (#26038571)
This is not true, Rust woudn't prevent anything in most cheats / issues you see in online games. 99% of them are busines logic related.