Can a Rust program hypothetically have this problem? Yes. Is it likely to show up often? No. Deliberately using uninitialized memory requires the MaybeUninit type and an unsafe block. It's very difficult to use uninitialized memory accidentally.
>It's very difficult to use uninitialized memory accidentally. >what is in-line assembly?
it takes two seconds to make rust completely unsafe, defeating its entire purpose.
And it's taken 5 decades and counting to try to make C safe, and the best they could come up with was an entirely new language instead. All the projects attempting to make C programming less error prone in-place with linters/sanitizers/AI magic always limit themselves to detecting a very narrow set of bugs at runtime (asan/msan/tsan work, and are great at their narrow tasks, and catch most bugs most of the time) or inevitably become new language projects (cyclone, verona, wuffs, etc. And Rust).
You cant use standard library memory allocators in kernel space, it requires your own functions. Sometimes you want uninitialized memory for performance, sometimes you dont for security. In such cases there is no practical difference between C and rust because you need to implement the functions in both languages and they could have the same name. It would be the exact same thing. It's not inherently a C problem, it's an optimization problem.
>You cant use standard library memory allocators in kernel space, it requires your own functions
You can plug your own allocator into Rust's standard library, either globally or per object (though the latter is unstable). They do it here: https://gitlab.com/linux-kernel/linux-next/-/blob/master/rust/kernel/allocator.rs
The standard library promises it won't let you access uninitialized memory without unsafe, and it keeps that promise even if you swap out libc's malloc/realloc for Linux's krealloc.
I don't know what it looks like when memory is moved from kernelspace to userspace though.
No. Rust doesn't let you use the value of an unitialized value.
neither does basically any modern language
>unitialized value.
variable*
OP was asking about rust
> it relies on C libraries all over the place
what C libraries
it literally uses libc and let's not mention all these crates that bundle C code and people use without a second thought
>it literally uses libc
Which libc? GNU libc? Musl?
moron
You can create uninitialized memory in Rust (AND THATS A GOOD THING!): https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html
brainlet who has never written a performant program in his entire life
Ah yea, I forgot about unsafe
most c compilers will swear at you if you attempt to as well
Cool, rust just won't compile.
Yes, it relies on C libraries all over the place and you'll see your "rust" program segfault.
So rust protects you against noob errors?
Can a Rust program hypothetically have this problem? Yes. Is it likely to show up often? No. Deliberately using uninitialized memory requires the MaybeUninit type and an unsafe block. It's very difficult to use uninitialized memory accidentally.
>It's very difficult to use uninitialized memory accidentally.
>what is in-line assembly?
it takes two seconds to make rust completely unsafe, defeating its entire purpose.
>seatbelts are pointless because you can take them off
And it's taken 5 decades and counting to try to make C safe, and the best they could come up with was an entirely new language instead. All the projects attempting to make C programming less error prone in-place with linters/sanitizers/AI magic always limit themselves to detecting a very narrow set of bugs at runtime (asan/msan/tsan work, and are great at their narrow tasks, and catch most bugs most of the time) or inevitably become new language projects (cyclone, verona, wuffs, etc. And Rust).
You cant use standard library memory allocators in kernel space, it requires your own functions. Sometimes you want uninitialized memory for performance, sometimes you dont for security. In such cases there is no practical difference between C and rust because you need to implement the functions in both languages and they could have the same name. It would be the exact same thing. It's not inherently a C problem, it's an optimization problem.
>You cant use standard library memory allocators in kernel space, it requires your own functions
You can plug your own allocator into Rust's standard library, either globally or per object (though the latter is unstable). They do it here: https://gitlab.com/linux-kernel/linux-next/-/blob/master/rust/kernel/allocator.rs
The standard library promises it won't let you access uninitialized memory without unsafe, and it keeps that promise even if you swap out libc's malloc/realloc for Linux's krealloc.
I don't know what it looks like when memory is moved from kernelspace to userspace though.
Rust sisters where can I buy hrt?
Higher Ranked Trait bounds has been stabilized since v1.0.
Rust is pedantic about uninitialized memory, but buffer reuse is "safe" and has similar risks.
I don't know how this affects kernels.
> corporation that's invested millions of dollars in <competing language> makes moronic claims
shocking.
Having uninitialized arrays are useful for highly optimized math functions
>leaking uninitialized kernal memory
No, but they do leak shit and puss from the rotting hole where their dick used to be.