logoalt Hacker News

uecker • today at 8:25 AM • 1 reply • view on HN

The fallacy is the idea that a Rust implementation would automatically achieve the same performance, and not resort to "unsafe" to be competitive, and then be open to exactly the same issues.

Illustrative example: This CVE in a Rust matrix transpose code: https://github.com/advisories/GHSA-5gmm-6m36-r7jh

Conceptually, there is not really anything much simpler than a matrix transpose. So how did they manage to create a bug? To make it fast you need simd, which implied using unsafe, and the dimension check to make it safe used unsigned integers that could wrap around. So they same bullshit as in C.


Replies

athrowaway3z • today at 9:58 AM

Your fallacy is that you present the comparison 'if' either of the two can be done poorly.

Rust can separate the question: "Is a set of functions is safe in a certain condition" from "using functions in that condition".

They are materially different. SIMD has a safe interface now.

➕ show 1 reply