• sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      2
      ·
      edit-2
      11 hours ago

      No, it’s a panic, so it’s more similar to a segfault, but with some amount of unwinding. It can be “caught” but only at a thread boundary.

      • calcopiritus@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        2 hours ago

        An unhanded error will always result on a panic (or a halt I guess). You cannot continue the execution of the program without handling an error (remember, just ignoring it is a form of handling). You either handle the error and continue execution, or you don’t and stop execution.

        A panic is very far from a segfault. In apparent result, it is the same. However, a panic is a controlled stopping of the program’s execution. A segfault is a forced execution stop by the OS.

        But the OS can only know that it has to segfault if a program accesses memory outside its control.

        If the program accesses memory that it’s under it’s control, but is outside bounds, then the program will not stop the execution, and this is way worse.

        EDIT: As you said, it’s also an important difference that a panic will just stop the thread, not the entire process.