• MotoAsh@piefed.social
    link
    fedilink
    English
    arrow-up
    42
    arrow-down
    1
    ·
    edit-2
    2 days ago

    Wait, is rust supposed to have intrinsic race condition protection? I thought its big feature was figuring out freeing memory for the dev instead of relying on runtime solutions or manual instructions… If it’s not supposed to magically fix possible race conditions, I don’t know how this issue is the language’s fault.

    • tyler@programming.dev
      link
      fedilink
      arrow-up
      78
      ·
      2 days ago

      It’s not. It’s literally code in an unsafe block. The OP is either trolling or actually ignorant.

        • xylogx@lemmy.world
          link
          fedilink
          English
          arrow-up
          62
          arrow-down
          1
          ·
          2 days ago

          Not only unironic but explained in the doc you referenced:

          However Rust does not prevent general race conditions.

          This is mathematically impossible in situations where you do not control the scheduler, which is true for the normal OS environment.”

    • FishFace@piefed.social
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      1
      ·
      1 day ago

      It is, in large part. The rules on ownership and borrowing mean that it is not supposed to be possible to change memory that something else can be concurrently reading from. That means you are forced to obtain references through protective mechanisms, which should protect from race conditions.

      All of that can go out of the window if you use unsafe.

      • MotoAsh@piefed.social
        link
        fedilink
        English
        arrow-up
        5
        ·
        1 day ago

        Note how the ticket cited is in an unsafe block, because it uses the OS scheduler, not its own. It is not Rust’s fault.

        • anton@lemmy.blahaj.zone
          link
          fedilink
          arrow-up
          4
          ·
          18 hours ago

          Rust doesn’t have a scheduler.
          The issue is the false assumption, that the remove operation can safely be done without taking a lock. This can be done in some specific data structures using atomic operations, but here the solution was to just take the lock. The same thing could have happened in a C code base but without the unsafe block indicating where to look for the bug.

        • FishFace@piefed.social
          link
          fedilink
          English
          arrow-up
          3
          ·
          1 day ago

          Yeah, I’m not saying it’s rust’s fault. Restricting this to unsafe makes it a lot easier to reason about where such problems can occur.

          I just don’t think anyone should give the impression that rust’s memory safety is not about race conditions.