Friday, May 29, 2015

Some Bugs Happen When Disabling Debug Message

We sometimes find a hard bug that only happens on disabling debug. It is hard to fix because if we enable debug, the bug disappears.  In my experience, we can summarize the list that are principles of tracing source code.

1) Need to add delay.

We need to add delay-time to wait a response from a device. If we disable debug, we lost delay-time so that a bug occurs.

2) A variable must be initialized.

Sometimes an uninitialized variable will be got a good value when debug is enabled. If we disable debug, the value of uninitialized variable is bad so that a bug occurs.

3) Check the bound of a buffer.

We are always easy to write data out of a buffer. If we enable debug, the data doesn't affect our program. But if we disable debug, the data may crack our program.


No comments:

Post a Comment