2
8 Comments

Where can I do hands on on finding root cause of software bugs?

I'm trying to learn a proper way of finding the root cause of software bugs? My seniors are telling me that I always failed to identify the root cause.

Thus I would like to practise more online to have a better idea on how to identify.

on January 19, 2021
  1. 4

    Do you have a more concrete example you can share?

    IME, on a small scale, I see this happen a lot when people don't even read the error message their application shows them when it fails. And then when they do read it they just try to make that error go away rather than understand why it was there.

    For example, say in Python you have a KeyError for the string 'firstname' in a dictionary. There are a few things that could be going on:

    1. Could be that the author made a wrong assumption about 'firstname' being in the dictionary.
    2. It could be that the caller of the function passed in the wrong type of value.
    3. Could be that some function way upstream didn't properly validate input.

    I've seen a lot of code where someone just changes the code to firstname = myvalue.get('firstname') which stops the error from being thrown and is correct if the issue is (1), but totally wrong and adding more bugs to the system if the issue is (2) or (3).

    1. 2

      for my case, its trying to identify from legacy code which there isn't any documentation and with limited data. Worse the legacy code is very tightly coupled so it make debugging very difficult.

      Thank you for giving couple of suggestions. Especially point 2! That actually helps!

  2. 3

    I would say, learn to use the debugger and writing tests.

    When I get to a problem I normally debug it first. Trying to replicate the problem locally is the first step. This normally includes copying the data from production into the local development version - this can be achieved in many ways.

    Now I am going to open the debugger. In JavaScript you could use the debugger keyword to debug in the browser and a little handy tool called ndb if you use Node.js. For other languages there will be similar tools (Jetbrains IDEs are great).

    I will debug the suspected code and just step through things step by step, figuring out if data fetching is done right, where the data is transformed and then put out (input - transformation - output is the usual path for functionalities). Once this is done and I spot something weird, hence you need some understanding of the functionalities, I will write a test to validate what is happening and should not happen. When that is done I can dive deeper into each steps to see what is wrong, you should know by then if getting data, transforming the data or the output of the data is the troublemaker based on your previous explorations. Then it is time to go as deep into the code to spot the actual error. Fix that and make the test run and voila.

  3. 3

    Check out Ministry of Testing, lots of stuff there all about testing software.

  4. 2

    to me that means you did not analyse and understand why it happens. once you do that you can also recommend how to fix it and avoid simmilar issues in the future.