Email or username:

Password:

Forgot your password?
Top-level
Mans R

@Gankra Rewriting the old code is also almost guaranteed to introduce new bugs, just not of the memory corruption kind.

8 comments
Ted Mielczarek

@mansr @Gankra my experience with rewriting existing code (C++, Python) in Rust has overwhelmingly consisted of finding latent bugs in the original code.

Mans R

@tedmielczarek @Gankra That just means you haven't found the new ones yet. Also, nothing stops you computing an invalid index in Rust. Simply translating the code won't remove the bugs, only limit their consequences (which isn't a bad thing).

Gankra

@mansr @tedmielczarek "i ported the code faithfully and now it constantly crashes on tripped assertions" tends to result in a lot of bugs being removed :)

(also faithfully porting the C code is impossible anyway because of the curse of integer promotion and the like... which is pure upside to lose in the translation and will probably randomly remove several bugs)

Mans R

@Gankra @tedmielczarek Those assertions will only be tripped if your testing covers those cases, which it probably doesn't, or you would have already found the bugs.

There is also no guarantee that fixing type mismatches won't add bugs as well as remove some. I'd even say it's quite likely, having seen the mayhem caused by people "fixing" compiler warnings in C code without understanding it properly.

Mans R

@Gankra @tedmielczarek Don't get me wrong, built-in buffer overflow prevention is great, but wholesale code rewrites are much more risky than people seem willing to admit.

Gankra

@mansr you don't need to add any new tests/assertions, boring rust code will slap hundreds of new implicit assertions between unwraps(), bounds checks, and overflow checks and the like

Mans R

@Gankra If the C code passes your testing, then those tests are unlikely to trip any of the new (implicit) checks. That doesn't mean there are no bugs.

Ted Mielczarek

@mansr @Gankra you are moving the goal posts here but sure.

Go Up