• 0 Posts
  • 66 Comments
Joined 1 year ago
cake
Cake day: May 10th, 2024

help-circle







  • The only way to make Rust segfault is by performing unsafe operations.

    Challange accepted. The following Rust code technically segfaults:

    fn stackover(a : i64) -> i64 {
        return stackover(a);
    }
    
    
    fn main() {
        println!("{}", stackover(100));
    }
    

    A stack overflow is technically a segmentation violation. At least on linux the program recives the SIGSEGV signal. This compiles and I am no rust dev but this does not use unsafe code, right?

    While the compiler shows a warning, the error message the program prints when run is not very helpfull IMHO:

    thread 'main' has overflowed its stack
    fatal runtime error: stack overflow
    [1]    45211 IOT instruction (core dumped)  ../target/debug/rust
    

    Edit: Even the compiler warning can be tricked by making it do recusion in pairs:

    fn stackover_a(a : i64) -> i64 {
        return stackover_b(a);
    }
    
    fn stackover_b(a : i64) -> i64 {
        return stackover_a(a);
    }
    
    fn main() {
        println!("{}", stackover_a(100));
    }
    










  • weker01@sh.itjust.workstoScience Memes@mander.xyzimagine
    link
    fedilink
    English
    arrow-up
    15
    ·
    5 months ago

    That is a reason why most farmers like to purchase seeds every season anyways. It’s way more predictable and you may want to change the strain depending on many variables.

    Farming, especially commodity crops like wheat, is an extremely risky business. Taking out some risk is often worth it.

    Modern farming is way more complicated and scientific than most people realize. The portrayal of farmers as bumbling idiots in popular media is not helping.