How do you reproduce bugs that occur sporadically?

前端 未结 28 1228
离开以前
离开以前 2021-01-30 19:43

We have a bug in our application that does not occur every time and therefore we don\'t know its \"logic\". I don\'t even get it reproduced in 100 times today.

Disclaime

28条回答
  •  抹茶落季
    2021-01-30 20:34

    This varies (as you say), but some of the things that are handy with this can be

    • immediately going into the debugger when the problem occurs and dumping all the threads (or the equivalent, such as dumping the core immediately or whatever.)
    • running with logging turned on but otherwise entirely in release/production mode. (This is possible in some random environments like c and rails but not many others.)
    • do stuff to make the edge conditions on the machine worse... force low memory / high load / more threads / serving more requests
    • Making sure that you're actually listening to what the users encountering the problem are actually saying. Making sure that they're actually explaining the relevant details. This seems to be the one that breaks people in the field a lot. Trying to reproduce the wrong problem is boring.
    • Get used to reading assembly that was produced by optimizing compilers. This seems to stop people sometimes, and it isn't applicable to all languages/platforms, but it can help
    • Be prepared to accept that it is your (the developer's) fault. Don't get into the trap of insisting the code is perfect.
    • sometimes you need to actually track the problem down on the machine it is happening on.

提交回复
热议问题