The final result is actually a small error.
But it takes a long time to locate the error...
Background: The error code is a program running on a Linux server. The main function of the program is to process bank POS Card swiping records and perform some calculations, and finally summarize and format the output.
The company deals with banks, and the projects it receives are all banks.
The next day I came to the company (the first day I was familiar with the environment and didn't do anything), the boss gave me a pure C program with over 2000 lines, A test document with test errors and output results with errors.
For historical reasons ..... This section of the program has been supplemented by many people, a master file without header files, wood code reuse, more than 2000 lines ......
In addition, I have just been unable to understand business knowledge and even test cases, like reading tianshu.
I tried to use vs to open the program. I rely on it and cannot run it in windows. It calls many library functions in Linux ....
Fortunately, I will use Linux, and I have cygwin installed on Windows ....
The program running environment is not a problem, and can run normally. I will start to track bugs. I don't know where the errors are. I don't understand the business knowledge, I don't know what the correct result is... Decisively ask the boss, where the results are not much ....
Okay, you know where the error is. Next, locate it. It's good to read the code in Vim. Now you should be familiar with vim, I can't understand the variable name and function name in the code. I can't understand the business knowledge of programmers... Bite your head,
Find some variables related to the error information and start GDB debugging ..........
.....
Finally, the error location of the problem is locked: atol function... Haha ....
This section of the program means that the processed data is obtained from the bank, such as pos card consumption information... There are big numbers in it. The atol () function only supports 8 bits. If it is changed to Atoll (), it will be pulled ....
Summary:
Overflow will not cause errors in the program, but will lead to incorrect results. Be sure to accept the lessons learned this time.
[Trouble shoot] atol and Atoll