Test example・Non-memory dynamic resource leak test
- 1. Memory is not the only leak in embedded software
- 2. Overlooked dynamic management table entry leak
- 3. Be careful if you have dynamic memory prepared by the app
- 4. Be careful of sockets as a dynamic resource provided by the OS
- 5. Each leak test required for all dynamic resources
- 6. Next to the leak test is a timer or counter rollover test.
Memory is not the only leak in embedded software
It is an important requirement for embedded software to continue to operate stably. In the previous article, we introduced testing for memory leaks that interfere with stable operation, but it is not only the dynamic memory provided by the OS that is at risk of leaks . The dynamic management table entries prepared in the application and the communication sockets and port numbers provided by the OS are also dynamic resources similar to dynamic memory, so there is a risk of leakage . This article introduces leak testing of dynamic resources other than dynamic memory.
Overlooked dynamic management table entry leak
In the case of application software that has a server function that accepts processing from other software, it has a management table inside and a dynamic management table that registers processing requests from other software in that management table. It may also implement the function of. For example, imagine server software A that implements the following functions.
- Server software A receives processing requests from multiple user software, executes processing in order, and returns a response.
- When server software A receives a processing request from software B, it registers software B in the internal management table.
- When the server software A finishes executing the processing request from the software B, the server software A returns the result to the software B.
- Server software A deletes the registration of software B from the management table after returning the result to software Bni.
In item 2 , register software B in the internal management table, and in item 4 , delete the registration of software B from the management table . This is because the management table entry is acting as a dynamic resource because there is a register / delete operation in the management table . Then, for example, if an error C occurs in the processing of the software B on the server A and an error response is returned to the software B, and the registration of the software B is forgotten to be deleted from the management table , the error C occurs. Every time an error occurs, the garbage registered in Software B will accumulate in the management table . This is a leaking management table entry . If the management table entry leak progresses and all management table entries are filled with garbage, server software A will not be able to accept subsequent processing requests.
Although it is expressed as a management table, if there is a mechanism to accept multiple processes when implementing the server function, a data structure that manages multiple processes is always required inside . There are various data structures, such as management tables and queues waiting to be processed . There are various data structures, but if there is a process of registration and deletion, it is a dynamic resource and there is a risk of leakage, so it is necessary to perform a leak test.
The dynamic resource leak test in this case is fairly easy. Since the initial value of the amount of dynamic resources prepared inside the software is known, the remaining amount of dynamic resources has not decreased after performing various operations such as using dynamic resources for the software. You can check if there is a leak by checking.
Be careful if you have dynamic memory prepared by the app
In recent embedded software, the number of software structures that have a server function inside has increased. In the case of software that has a server function, in addition to the management information for managing processing requests from other software as described above , dynamic resources are often implemented for internal processing .
For example, taking the above server software A as an example, if a variable length area is required as a data buffer area to be used for internal processing , the maximum size x the maximum number of processed memories can be statically acquired to obtain a huge size. Therefore, we will implement a mechanism to reuse the internal memory as needed.
This, turn to use the internal memory as needed because, after all dynamic memory dedicated mounted on the inside the same as, the process of acquisition / release exists. It say that, leak of this memory and will divulge the release process takes place it will be in it, for the dynamic resources that are used in this kind of internal processing also requires a leak test.
Be careful of sockets as a dynamic resource provided by the OS
The dynamic resources provided by the OS are other than dynamic memory, and in rare cases, these dynamic resources may leak . A relatively common leak is a socket or port number used for communication between software . In the experience of Gutara’s father, a socket close processing omission during product abnormal processing caused a malfunction due to socket depletion in the market . Due to the structure of the software, the port number leaked at the same time as the socket, but at this time, the socket was exhausted earlier due to the system configuration, causing a malfunction.
It was a communication function for remote maintenance that the socket was exhausted and could not be used , so there was no recovery means and I was in great trouble. The condition for socket depletion is repeated login to the remote maintenance function in a communication environment where errors occur frequently , but in the in-house test before the release, only the operation acceleration test in an error-free communication environment was performed, so this The socket leak could not be detected.
Each leak test required for all dynamic resources
A dynamic resource leak appears as a software malfunction only when the remaining amount of the resource gradually decreases as the conditions for the leak occur repeatedly, and at some point the remaining amount becomes zero . Therefore, in the pre-shipment test, if the leak test is not performed properly for the purpose of detecting resource leaks, potential leak bugs of dynamic resources will be overlooked.
In the leak test of dynamic resources, washout of dynamic resources where there is a possibility of leakage and accelerated method of processing happens to leak because two of becomes important, let’s firmly study.
Next to the leak test is a timer or counter rollover test.
For detection time bomb bugs lurking in the embedded system software, important to the next leak test of the memory and dynamic resources, rollover test timer or counter to. We’ll talk about this in the next article.
Discussion
New Comments
No comments yet. Be the first one!