News for hackers. Stuff that matters.
Re:Some mistakes Rust doesn't catch by kjeetgill on Tuesday February 08, 2022 @03:44AM (#30256164)
That reminds me of my favorite bug in a C program I ever delt with. We had a dorm floors' worth of "Intro to C" students pouring over our friend's buggy program.

With a enough printfs() I was able to whittle the problem down to: A local variable "b" was changing after some function call that looked like: "call(&a)". Turns out because our program looked like "{ int a[3]; int b; ... call(&a); }" an off by one error accessing "a[4]" in the function was overwriting variables never passed to it!

Felt like the champ figuring out. (This is a 15 year old story from freshman year, so I hope I got the details right.)

Re:Some mistakes Rust doesn't catch by kjeetgill on Tuesday February 08, 2022 @05:46PM (#30265932)
Update, since this got attention: I remembered slightly wrong: "b" would need to be declared before "a", not after and you'd access it with "a[3]" not "a[4]". So after this, "b" would be 7: "int b=5; int a[3]; a[3]=7;". Looks like I'm still making the same mistakes.

But still: If you passed the array and referenced it wrong it would change local variables in some remote stack frame.

Re:Some mistakes Rust doesn't catch by cozzyd on Tuesday February 08, 2022 @04:41AM (#30256527)
valgrind is your friend!
Re:Some mistakes Rust doesn't catch by benibela on Tuesday February 08, 2022 @12:02PM (#30260983)
That does not really work for stack variables
Re:Some mistakes Rust doesn't catch by renox on Wednesday February 09, 2022 @03:32AM (#30270347)
There is ASAN https://github.com/google/sanitizers/wiki/AddressSanitizer which may work for stack variable though.
Re:Some mistakes Rust doesn't catch by nindalf on Tuesday February 08, 2022 @04:05AM (#30256295)
That’s horrifying.