• AMDIsOurLord@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    The developer must either provide the logging and attach a debugger or go get fucked when a runtime error happens

    • drolex@sopuli.xyz
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      You can also debug post-mortem with the minidump or the core dump file with WDT on Windows. Great fun and a good way to brush up on your assembly skills

      • marcos@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Great fun and a good way to brush up on your assembly skills

        Just load it on the debugger and leave your asm skill gather patina.

    • Faresh@lemmy.ml
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      1 year ago

      That’s not true though. You can get the backtrace and other useful information from the coredump mentioned by the error message by loading it with gdb. Not as good as attaching it to a living process, since you can’t see step-by-step what happens leading up to the error, but still quite useful.

      • AMDIsOurLord@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Well yes, that’s a pretty good way of debugging a third party app but if you are developing something you can have more ease with gdb attached

    • It actually is if you known how to read it. It’s extremely verbose, but you can follow any exception down to the exact line of code (or JNI call, I guess) where the problem occurs. I’ll gladly take the kilobytes

      Unfortunately, Java programmers seem to hate actually handing errors, so you see a lot of try{} catch (Exception e) { throw System.println("something went wrong");} ruining your life, but that’s not the language’s fault.

      • merc@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        but you can follow any exception down to the exact line of code (or JNI call, I guess) where the problem occurs.

        But, it’s not really where the problem occurred. How often do you get a stack trace and the bug fix is at the line referenced by the stack trace? Almost never. It’s more that it takes you down to the exact line of code where the effects of the problem are bad enough to affect the running of the program. But, the actual problem happened earlier, sometimes much earlier.

        For example, NullPointerException isn’t actually the problem, it’s a symptom of the problem. Something didn’t get initialized properly, and nobody noticed for a while, until we tried to use it, and got a null pointer. Sometimes it’s easy to go from the effect (null pointer) to the cause (uninitialized thing). But, other times that “thing” was passed in, so you have to work backwards to try to figure out where that thing comes from, and why it’s in that broken state.

        Sure, it’s better than nothing, but it’s still frustrating.

        • When reproducing a bug? Most of the time. Reasoning back from the variable name and location of a null dereference with a provided call path is much more than you get with tons of languages, especially when calls from frameworks or external libraries enter the mix.

          It won’t tell you exactly what to fix, you’ll need to debug for that (C# does some black magic to allow you to do that, Java doesn’t come close to the capabilities of full fat Visual Studio), but you won’t need to waste any time deciphering where the program crashed.

          Every crash is frustrating, but the stack traces themselves are super useful.

      • kbal@fedia.io
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Super-advanced java devs like me do it like try{} catch (Exception e) { System.out.println("something went wrong); e.printStackTrace(); }

            • tool@lemmy.world
              link
              fedilink
              English
              arrow-up
              0
              ·
              1 year ago

              On Error Resume Next never before have more terrible words been spoken.

              Every time I’m reading a PowerShell script at work and see -ErrorAction SilentlyContinue I want to scream into a pillow and forcefully revert their commit.

              I’ve actually done it a few times, but I want to do it every time.

      • lowleveldata@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        you can follow any exception down to the exact line of code

        Which is usually not a piece of code written by us and is caused by another piece of code not written by us either

        • MyNameIsRichard@lemmy.ml
          link
          fedilink
          arrow-up
          0
          ·
          edit-2
          1 year ago

          Does your IDE not highlight the lines written by you in a different colour? Of course that doesn’t help when it’s an error in production!

        • I don’t know any programming language where that isn’t the case, though. Unless you’re writing another SerenityOS, you’ll probably use external frameworks and libraries to take care of all the uninteresting stuff.

      • marcos@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        The same applies to using the core dump.

        In fact, the Python one is the lest useful of the trio.

        • xmunk@sh.itjust.works
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          When the day comes that you need gdb you will indeed be amazed at how fucking powerful it is. If your server crashes grab that core dump!

    • Aurenkin@sh.itjust.works
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      I think it’s pretty useful, be interested to hear your hangups with it though because it’s definitely not perfect.

      If something goes wrong and I have a stack trace, that plus the type of exception will almost always be enough for me to figure out what’s wrong at least as a starting point. I’ve worked mostly with JVM languages in my career though so maybe I just don’t know how bad it actually is.

  • FlatFootFox@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    My favorite compile error happened while I was taking a Haskell class.

    ghc: panic! (the ‘impossible’ happened)

    The issue is plainly stated, and it provides clear next steps to the developer.

  • Strykker@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    Except the C++ “Core dumped” line is telling you it just wrote a file out with the full state of the program at the time of the crash, you can load it up and see where it crashed and then go and look at what every local variable was at the time of the crash.

    Pretty sure you can even step backwards in time with a good debugger to find out exactly how you got to the state you’re currently in.

          • current@lemmy.ml
            link
            fedilink
            arrow-up
            0
            ·
            1 year ago

            i mean you’re expected to know the basic functioning of the compiler when you use it

          • ysjet@lemmy.world
            link
            fedilink
            English
            arrow-up
            0
            ·
            1 year ago

            Imagine if you knew the most basic foundational features of the language you were using.

            Next we’ll teach you about this neat thing called the compiler.

            • Russ@bitforged.space
              link
              fedilink
              English
              arrow-up
              0
              ·
              1 year ago

              I’m not a C/C++ dev, but isn’t apport Ubuntu’s crash reporter? Why would dumps be going into there?

              Though on a rhetorical thought, I am aware of systemd’s coredumptctl so perhaps its collecting dumps the same way systemd does.

              • ysjet@lemmy.world
                link
                fedilink
                English
                arrow-up
                0
                ·
                edit-2
                1 year ago

                https://wiki.ubuntu.com/Apport

                It intentionally acts as an intercept for such things, so that core dumps can be nicely packaged up and sent to maintainers in a GUI-friendly way so maintainers can get valuable debugging information even from non-tech-savvy users. If you’re running something on the terminal, it won’t be intercepted and the core dump will be put in the working directory of the binary, but if you executed it through the GUI it will.

                Assuming, of course, you turn crash interception on- it’s off by default since it might contain sensitive info. Apport itself is always on and running to handle Ubuntu errors, but the crash interception needs enabled.

              • TarantulaFudge@lemmy.ml
                link
                fedilink
                arrow-up
                0
                ·
                1 year ago

                I love gdb! I recently had to do a debug and wow its so cool! On gentoo I can compile everything with symbols and source and can do a complete stack trace.

              • TangledHyphae@lemmy.world
                link
                fedilink
                arrow-up
                0
                ·
                1 year ago

                Am I the only one in this thread who uses VSCode + GDB together? The inspection panes and ability to breakpoint and hover over variables to drill down in them is just great, seems like everyone should set up their own c_cpp_properties.json && tasks.json files and give it a try.

              • inetknght@lemmy.ml
                link
                fedilink
                arrow-up
                0
                ·
                1 year ago

                …unless you build the executable with optimizations that remove the stack frame. Good luck debugging that sucker!

  • Subverb@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    Nevermind that the C++ program is two orders of magnitude faster when completed.

    I would love to learn and use Rust but I’m a embedded systems guy. Everything of consequence is C and C++.

  • ElCanut@jlai.lu
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    1 year ago

    Rust developer: I’d like to compile some code

    Rust compiler: the fuck you are

    • Malle_Yeno@pawb.social
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      The rust compiler holds your hand, wraps you in blankets, makes you hot chocolate, kisses you on the forehead before it gently and politely points out what you did wrong and how you can solve it step-by-step. It would never think of something as heinous as swearing at you, shame on you for insulting my wife’s honour like this.

      • hector@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        I don’t know from where this legend comes from but lifetimes/concurrency/macros errors are brain-hurting.

        Most of the time I find myself dropping project because I wrote my program in a correct way but Rust just does not like how it is designed lol. I can’t get shit done with this language

      • ElCanut@jlai.lu
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Rust compiler is passive agressive, like:

        “There’s an error at line 286 because you still don’t know how to use the borrow checker after all this time ♥️”

        • deur@feddit.nl
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          its a compiler. That is at best projection, especially considering how the compiler’s error feedback is designed to be firm yet gentle.

      • _xDEADBEEF@lemm.ee
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        except when it gives errors about lifetimes of some object.

        boy, that makes my brain hurt

      • planish@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        The rust compiler produces a flawless understanding of your code, and then quits out because understanding that code is a Nightly-only feature and you’re using the stable build.

  • voxel@sopuli.xyz
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    1 year ago
    gdb ./fuck
    r
    where
    

    you should get a complete stack trace (complete with values of some function arguments)

  • Flxibit@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    This C++ message has an urgency vibes to it:

    “Segmentation fault!! Drop the Nuclear Reactor quick!!”