Reply to post: C / C++ compilers and libc could do this too

Rust in peace: Memory bugs in C and C++ code cause security issues so Microsoft is considering alternatives once again

Anonymous Coward
Anonymous Coward

C / C++ compilers and libc could do this too

You don't need to rewrite everything from scratch in a new language, use a compiler that sanity checks things and won't allow e.g. strcpy(a,b) and inserts run time sanity checks where possible, inserts code to zero memory on the stack before allocation and so on. Libraries like libc etc. could add some sanity checking of arguments, system call stubs could do - not only catch security issues but crash issues.

I'm not saying you can make C as safe as Rust, but you can damn sure make it WAY safer than it is out of the box, with no perceptible performance penalty. 30 years ago you wouldn't want to do the stuff I'm suggesting because every cycle mattered. A lot of run time checks wouldn't slow down anything at all, since the code can be placed so it uses otherwise unused execution slots. Even if was a few percent slower if it is safer who cares? Rust isn't as fast as C, either.

Less and less code is performance sensitive every year as CPUs get faster and faster, and stuff that is (i.e. games and HPC) are not something where you care about security holes too much. Compile those with --safety-off.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon