• dhork@lemmy.world
    link
    fedilink
    English
    arrow-up
    132
    arrow-down
    2
    ·
    1 day ago

    Just because you’re writing in a shiny new language that never misses an opportunity to crow about how memory safe it is, doesn’t mean that you can skip due diligence on input validation, checking every return value and writing exception handlers for even the most unlikely of situations.

    Lol

      • Noja@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        23
        arrow-down
        2
        ·
        21 hours ago

        Memory leaks are logic errors, Rust can’t really prevent you from leaking memory.

          • Mechanize@feddit.it
            link
            fedilink
            English
            arrow-up
            19
            ·
            edit-2
            19 hours ago

            You can leak memory in perfectly safe Rust, because it is not a bug per se, an example is by using Box::leak

            Preventing memory leaks was never in the intentions of Rust. What it tries to safeguard you from are Memory Safety bugs like the infamous and common double free.

            • 8uurg@lemmy.world
              link
              fedilink
              English
              arrow-up
              1
              ·
              41 minutes ago

              And it still cleans up once the ownership model indicates it can be cleaned up. That does not ensure memory is never leaked, but it is equivalent to destructors running automatically when using unique ptr or shared ptr without cycles in C++, which avoids at least a portion of possible memory leaks.

        • socsa@piefed.social
          link
          fedilink
          English
          arrow-up
          6
          ·
          20 hours ago

          Some memory leaks are logic errors, and this is honestly the irony of modern dynamic languages. I have actually gotten into the argument in interviews before - it is arguably safer (and better) to work from maximal static memory allocations with memory safe data objects than it is to implement dynamic memory algorithms just because they are fun coding problems.

    • wizardbeard@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      7
      ·
      16 hours ago

      I swear, every time I start to think that I go overboard with this sort of shit in my scripts for work, I either find another ridiculous edge case or a story like this comes out.