Fingerprint-based memory tracking method and device, equipment and medium
By intercepting requests, generating memory block sizes, allocating memory blocks and storing memory fingerprints during memory allocation, the existing memory tracking tools have been solved, and the problem of rapid memory usage is quickly achieved and software stability and reliability are improved.
Patent Information
- Application Number
- CN202411939719.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-05-13
AI Technical Summary
The existing memory tracking tools have problems such as high operating overhead, limited support for application scenarios and development environment.
By intercepting memory allocation requests, the memory block size is generated, and the original memory allocation function in the memory allocator allocates the memory block to allocate the memory block, storing the memory fingerprint at the memory block header, including call stack information, memory block size and MagicNumber, so as to quickly locate memory usage issues when needed.
It realizes rapid and accurate positioning of memory usage issues, improves the stability and reliability of the software, and supports a variety of platforms and development environments, reducing operating overhead.
Smart Images

Figure CN119988160A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software technology, and in particular to a fingerprint-based memory tracking method, device, equipment and medium. Background Art
[0002] In computer software systems, memory management is an important component. However, due to improper operation by programmers or program design defects, problems such as memory leaks and system crashes often occur. These problems are often difficult to investigate and locate, which brings great difficulties to software development and maintenance.
[0003] Existing memory tracking technologies mainly include operating system-level memory tracking tools and programming language-level memory tracking tools. Operating system-level memory tracking tools need to perform memory tracking at the operating system level, which is highly invasive to applications and has high performance overhead. Programming language-level memory tracking tools are mainly aimed at memory management of specific programming languages, and have limited support for other programming languages.
[0004] Standard libraries such as malloc in C language and new in C++ provide basic memory allocation functions, but do not have the function of tracking memory usage errors. Developers need to manage memory by themselves when using it, which often leads to potential memory leaks and misuse problems. Since memory allocation and recycling are very frequent, the efficiency of tracking technology is very high. The current typical technologies include the following tools and methods.
[0005] Platform-specific memory debugging tools:
[0006] Valgrind: A tool for memory error detection that can detect memory leaks, uninitialized usage, and other issues. It is widely used in Linux environments. It uses dynamic instrumentation technology to insert monitoring logic into the program while the program is running, analyzing each memory allocation and release operation. However, Valgrind introduces significant runtime overhead, and the real-time tracking effect for large applications is not ideal.
[0007] AddressSanitizer (ASan): A tool used in LLVM and GCC for memory error detection, which can detect problems such as out-of-bounds access, uninitialized memory read and write, etc. Although ASan can track more detailed error information, it consumes a lot of memory and runtime resources, especially in scenarios with frequent allocation and release.
[0008] Current memory tracking technologies are mostly limited to a single platform. For example, Valgrind and ASan mainly support Linux environments, but have limited support for embedded systems or cross-platform applications.
[0009] Traditional tools are usually not well adapted to large-scale, real-time demanding systems, such as high-performance computing (HPC) systems, IoT devices, etc. Summary of the invention
[0010] In view of this, an embodiment of the present invention provides a fingerprint-based memory tracking method to solve the technical problems of high operating overhead, limited supported application scenarios and development environments in the prior art memory tracking tools. The method includes:
[0011] Intercepting a memory allocation request, and generating a memory block size according to the number of requested memory bytes carried in the memory allocation request;
[0012] Calling the original memory allocation function in the memory allocator to allocate the current memory block based on the memory block size;
[0013] Storing a memory fingerprint in a header of the current memory block, the memory fingerprint including call stack information allocated to the current memory block, a memory block size of the current memory block, and a MagicNumber;
[0014] When memory tracking is required, the erroneous memory block is determined based on the memory address of the access error, and the code block with memory usage problem and the problem type are determined based on the memory fingerprint in the header of the erroneous memory block.
[0015] The embodiment of the present invention also provides a fingerprint-based memory tracking device to solve the technical problems of high operating overhead, limited supported application scenarios and development environments in the prior art memory tracking tools. The device includes:
[0016] An acquisition module, used for intercepting a memory allocation request and generating a memory block size according to the number of requested memory bytes carried in the memory allocation request;
[0017] A memory allocation module, used for calling the original memory allocation function in the memory allocator to allocate the current memory block based on the memory block size;
[0018] A fingerprint storage module, used to store a memory fingerprint in the header of the current memory block, wherein the memory fingerprint includes call stack information allocated to the current memory block, a memory block size of the current memory block, and a MagicNumber;
[0019] The memory tracking module is used to determine the erroneous memory block according to the memory address of the access error when memory tracking is required, and determine the code block with memory usage problem and the problem type according to the memory fingerprint in the header of the erroneous memory block.
[0020] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-mentioned fingerprint-based memory tracking methods when executing the computer program, so as to solve the technical problems of high operating overhead, limited supported application scenarios and development environment existing in the memory tracking tools in the prior art.
[0021] An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program for executing any of the above-mentioned fingerprint-based memory tracking methods, so as to solve the technical problems of high operating overhead, limited supported application scenarios and development environment of memory tracking tools in the prior art.
[0022] Compared with the prior art, the beneficial effects achieved by at least one of the above technical solutions adopted in the embodiments of the present specification include at least: generating a memory block size according to the number of requested memory bytes carried by a memory allocation request, calling the original memory allocation function in the memory allocator, and allocating the current memory block based on the memory block size, thereby allocating the memory block based on the original memory allocation function without changing the original memory allocation function; and then storing a memory fingerprint in the header of the current memory block (i.e., efficiently recording the location of each memory allocation (call stack, i.e., memory fingerprint), wherein the memory fingerprint includes the call stack information allocated to the current memory block, the memory block size of the current memory block, and the MagicNumber, so that the memory fingerprint can be directly bound to the allocated memory block, ensuring that the memory fingerprint will not be lost when the memory is released, so that when memory tracking is required In this case, the erroneous memory block is determined according to the memory address of the access error, and finally the code block with memory usage problem and the problem type can be determined according to the memory fingerprint in the header of the erroneous memory block, so that the memory usage problem can be quickly and accurately located based on the memory fingerprint, thereby improving the stability and reliability of the software; at the same time, the fingerprint-based memory tracking method does not depend on a specific operating system or programming language, has good portability, and can be implemented on multiple platforms, and can support different environments by adapting different memory allocators and programming language interfaces, can support a wider range of application scenarios and development environments, and is helpful to unify the memory tracking solution in cross-platform applications; in addition, the fingerprint-based memory tracking method can restore the location of the memory error based on the memory fingerprint only, and does not need to analyze each memory allocation and release operation, so as to help reduce the running overhead. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 is a flow chart of a fingerprint-based memory tracking method provided by an embodiment of the present invention;
[0025] Figure 2 It is a structural schematic diagram of a memory allocation block (or memory block) provided in an embodiment of the present invention;
[0026] Figure 3 It is a schematic diagram of a static table of hash values for recording call stack information provided by an embodiment of the present invention;
[0027] Figure 4 is a structural block diagram of a computer device provided by an embodiment of the present invention;
[0028] Figure 5 It is a structural block diagram of a fingerprint-based memory tracking device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0030] The following describes the implementation methods of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that, in the absence of conflict, the following embodiments and the features in the embodiments can be combined with each other. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work belong to the scope of protection of the present application.
[0031] In an embodiment of the present invention, a fingerprint-based memory tracking method is provided, such as Figure 1 As shown, the method includes:
[0032] Step S101: intercepting a memory allocation request, and generating a memory block size according to the number of requested memory bytes carried in the memory allocation request;
[0033] Step S102: calling the original memory allocation function in the memory allocator to allocate the current memory block based on the memory block size;
[0034] Step S103: storing a memory fingerprint in the header of the current memory block, the memory fingerprint including call stack information allocated to the current memory block, the memory block size of the current memory block, and MagicNumber;
[0035] Step S104: when memory tracking is required, the erroneous memory block is determined according to the memory address of the access error, and the code block with the memory usage problem and the problem type are determined according to the memory fingerprint in the header of the erroneous memory block.
[0036] Depend on Figure 1 As can be seen from the process shown, in the embodiment of the present invention, it is proposed to generate a memory block size according to the number of requested memory bytes carried by the memory allocation request, and call the original memory allocation function in the memory allocator, allocate the current memory block based on the memory block size, and realize the allocation of memory blocks based on the original memory allocation function without changing the original memory allocation function; and then store a memory fingerprint in the header of the current memory block (that is, efficiently record the location of each memory allocation (call stack, that is, memory fingerprint), the memory fingerprint includes the call stack information allocated to the current memory block, the memory block size of the current memory block and the MagicNumber, so that the memory fingerprint can be directly bound to the allocated memory block, ensuring that the memory fingerprint will not be lost when the memory is released, so that when memory tracking is required, according to the memory access error The erroneous memory block is determined by the address, and finally the code block with memory usage problem and the problem type can be determined according to the memory fingerprint in the header of the erroneous memory block, so that the memory usage problem can be quickly and accurately located based on the memory fingerprint, thereby improving the stability and reliability of the software; at the same time, the fingerprint-based memory tracking method does not depend on a specific operating system or programming language, and has good portability, so that it can be implemented on multiple platforms, and can support different environments by adapting different memory allocators and programming language interfaces, and can support a wider range of application scenarios and development environments, which is helpful to unify the memory tracking solution in cross-platform applications; in addition, the fingerprint-based memory tracking method can restore the location of the memory error based on the memory fingerprint, and does not need to analyze each memory allocation and release operation, which helps to reduce operating overhead.
[0037] In specific implementation, the fingerprint-based memory tracking method can be run in a memory allocator. Without changing the original memory allocation function, the memory allocator implements the process of storing the memory fingerprint in the header of the current memory block, so that when memory tracking is required, the erroneous memory block can be determined according to the memory address of the access error, and then the code block with memory usage problems and the type of problem can be determined according to the memory fingerprint in the header of the erroneous memory block, so as to realize the packaging of the existing memory allocator so that custom code can be inserted when allocating and releasing memory. This can be achieved through dynamic link library (DLL) injection, the hook mechanism provided by the programming language, or the API provided by the operating system.
[0038] In a specific implementation, in order to realize binding the memory fingerprint with the allocated memory block, it is proposed to store the memory fingerprint in the header of the current memory block, including:
[0039] At the head of the current memory block, before the original head information (i.e., the original head), a preset number of bytes are used to store the memory fingerprint, such as Figure 2 As shown, the call stack information, the memory block size of the current memory block and the MagicNumber (ie, the magic number) are stored in sequence from near to far from the original header information, and the original header information is returned to the user.
[0040] In specific implementation, that is, in the memory allocation function, when a memory block is allocated, the present application will capture the call stack to which the current memory block is allocated, and then store the call stack information in the header of the current memory block to achieve the recording and binding of the call stack. The call stack is a record of a series of function calls, each record containing the address of the function and other related information. The capture of the call stack can be achieved through the stack frame access interface provided by the programming language or the API provided by the operating system.
[0041] In specific implementation, the header of a memory block is a specific area used to store metadata related to the memory block. Figure 2 As shown, 12 bytes can be allocated before the original header information to fill in memory fingerprints such as MagicNumber, memory block size (i.e., size), call stack information (such as hash value), and then the original header address is returned to the user. Specifically, the original header information in the header of the memory block is the header information generated after the memory block is allocated using the existing memory allocation function.
[0042] In the specific implementation, in order to reduce the overhead of retaining stack records and realize online use, in order to further effectively reduce the call stack storage space and reduce the demand for memory, so that even in large-scale, high-frequency memory allocation and release scenarios, low resource consumption can still be maintained. It is proposed to use a static hash table to record the stack records of existing call stacks, and store the hash value of the call stack in the header of the current memory block. For example, the memory fingerprint is stored in the header of the current memory block, including:
[0043] Calculate the hash value of the call stack information, determine whether the hash value has been stored in the static table, if not, store the hash value in the static table (that is, store the call stack information and its corresponding hash value in the static table), and store the hash value in the header of the current memory block, wherein the static table uses the hash value of the call stack information as a key and the function address list of the call stack information as a value.
[0044] When implementing it, Figure 3 As shown, in a static hash table (i.e., HashMap, also called the above-mentioned static table), existing call stacks Bucket (such as Bucket1, Bucket2...BucketM, etc., M call stacks) are recorded, and a function address list (i.e., callstack) and a hash value (i.e., Hash value) corresponding to each call stack are stored. Each function address list callstack includes multiple function addresses funcaddr (such as funcaddr1, funcaddr2... funcaddrK, etc., K function addresses).
[0045] In specific implementation, in order to further avoid duplication of hash values of different call stack information and improve the accuracy of memory tracking, it is proposed to calculate the hash value of the call stack information, including:
[0046] Calculate an initial hash value according to the function address list in the call stack information;
[0047] The depth of the call stack is added to the initial hash value, and the final hash value is calculated again.
[0048] In specific implementation, in order to determine the problem type of the memory usage problem based on the memory fingerprint, it is proposed to determine the problem type of the memory usage problem according to the memory fingerprint in the header of the error memory block, including:
[0049] In the header of the error memory block, scan along the memory address of the access error to the lower address (that is, scan from the memory address to the MagicNumber direction in the header of the memory block) until the MagicNumber is found;
[0050] The number of bytes from the memory address of the access error to MagicNumber is calculated, and the problem type of the memory usage problem is determined according to the relationship between the number of bytes and the memory block size of the error memory block.
[0051] In a specific implementation, determining the problem type of the memory usage problem according to the relationship between the number of bytes and the memory block size of the erroneous memory block includes:
[0052] If the number of bytes is greater than the memory block size of the erroneous memory block, the memory usage problem is determined to be an address out-of-bounds problem; if the number of bytes is less than the memory block size of the erroneous memory block, the memory usage problem is determined to be wild pointer usage.
[0053] In specific implementation, in order to quickly trace back and locate the code area where the memory usage problem occurs based on the memory fingerprint, it is proposed to determine the code block with the memory usage problem according to the memory fingerprint in the header of the error memory block, including:
[0054] Determine a function address list of corresponding call stack information in a static table according to a hash value of the call stack information in the header of the error memory block;
[0055] The function call relationship is restored according to the function address list of the call stack information, and the code block with memory usage problem is determined based on the function call relationship.
[0056] In specific implementation, the fingerprint-based memory tracking method can achieve efficient memory tracking to solve difficult-to-investigate problems such as memory leaks and system crashes caused by improper memory usage. By wrapping the existing memory allocator, the entire call stack is recorded in the memory allocation function and placed in the header of the allocated memory block, so that when investigating memory usage problems, the corresponding memory block (i.e., the above-mentioned erroneous memory block) is determined according to the suspicious address (i.e., the memory address with an access error), and the call stack is restored according to the memory fingerprint in the header of the memory block, so as to determine in which code blocks there is memory misuse. It is achieved that the code area where memory usage problems (such as memory leaks, unreleased memory, etc.) occur can be quickly traced back and located without significantly increasing performance overhead, which is conducive to speeding up error troubleshooting and problem repair. The fingerprint-based memory tracking method can be widely used in a variety of scenarios that require memory management and performance optimization, including high-performance server applications, embedded system development, big data processing, machine learning applications, and scientific computing, especially those environments with high requirements for memory management.
[0057] In specific implementation, the fingerprint-based memory tracking method needs to ensure the atomicity and thread safety of operations when processing memory allocation and release to prevent data competition and memory corruption in a multi-threaded environment.
[0058] In specific implementation, the fingerprint-based memory tracking method can be implemented in a dynamic library manner, and the problem can be located based on the exported or generated core file combined with GDB (program debugging tool).
[0059] In this embodiment, a computer device is provided, such as Figure 4 As shown, it includes a memory 401, a processor 402, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any of the above-mentioned fingerprint-based memory tracking methods is implemented.
[0060] Specifically, the computer device may be a computer terminal, a server or a similar computing device.
[0061] In this embodiment, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program for executing any of the above-mentioned fingerprint-based memory tracking methods.
[0062] Specifically, computer-readable storage media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer-readable storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable storage media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0063] Based on the same inventive concept, a fingerprint-based memory tracking device is also provided in an embodiment of the present invention, as described in the following embodiments. Since the principle of solving the problem by the fingerprint-based memory tracking device is similar to that of the fingerprint-based memory tracking method, the implementation of the fingerprint-based memory tracking device can refer to the implementation of the fingerprint-based memory tracking method, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0064] Figure 5 is a structural block diagram of a fingerprint-based memory tracking device according to an embodiment of the present invention, such as Figure 5 As shown, including:
[0065] The acquisition module 501 is used to intercept a memory allocation request and generate a memory block size according to the number of requested memory bytes carried in the memory allocation request;
[0066] A memory allocation module 502 is used to call the original memory allocation function in the memory allocator to allocate the current memory block based on the memory block size;
[0067] A fingerprint storage module 503, configured to store a memory fingerprint in the header of the current memory block, wherein the memory fingerprint includes call stack information allocated to the current memory block, a memory block size of the current memory block, and a MagicNumber;
[0068] The memory tracking module 504 is used to determine the erroneous memory block according to the memory address of the access error when memory tracking is required, and determine the code block with memory usage problem and the problem type according to the memory fingerprint in the header of the erroneous memory block.
[0069] In one embodiment, the fingerprint storage module is used to store the memory fingerprint using a preset number of bytes at the head of the current memory block and before the original header information, and to store the call stack information, the memory block size of the current memory block and the MagicNumber in order from near to far from the original header information, and return the original header information to the user.
[0070] In one embodiment, a fingerprint storage module is used to calculate the hash value of the call stack information, determine whether the hash value has been stored in a static table, and if not, store the hash value in the static table and store the hash value in the header of the current memory block. The static table uses the hash value of the call stack information as a key and the function address list of the call stack information as a value.
[0071] In one embodiment, the fingerprint storage module is used to calculate an initial hash value according to the function address list in the call stack information; add the depth of the call stack to the initial hash value, and calculate again to obtain a final hash value.
[0072] In one embodiment, a memory tracking module is used to scan along the memory address where the access error occurred toward a lower address in the header of the erroneous memory block until the MagicNumber is found; calculate the number of bytes from the memory address where the access error occurred to the MagicNumber, and determine the problem type of the memory usage problem based on the relationship between the number of bytes and the memory block size of the erroneous memory block.
[0073] In one embodiment, the memory tracking module is used to determine that the memory usage problem is an address out of bounds if the number of bytes is greater than the memory block size of the erroneous memory block; if the number of bytes is less than the memory block size of the erroneous memory block, determine that the memory usage problem is a wild pointer usage.
[0074] In one embodiment, a memory tracking module is used to determine a function address list of corresponding call stack information in a static table according to a hash value of the call stack information in a header of the erroneous memory block; restore a function call relationship according to the function address list of the call stack information, and determine a code block with a memory usage problem based on the function call relationship.
[0075] The embodiment of the present invention achieves the following technical effects: it proposes to generate a memory block size according to the number of requested memory bytes carried by a memory allocation request, and calls the original memory allocation function in the memory allocator to allocate the current memory block based on the memory block size, thereby allocating the memory block based on the original memory allocation function without changing the original memory allocation function; and then stores a memory fingerprint in the header of the current memory block (i.e., efficiently records the location of each memory allocation (call stack, i.e., memory fingerprint), wherein the memory fingerprint includes the call stack information allocated to the current memory block, the memory block size of the current memory block, and the MagicNumber, so that the memory fingerprint can be directly bound to the allocated memory block, ensuring that the memory fingerprint will not be lost when the memory is released, so that when memory tracking is required, the memory fingerprint can be obtained according to the memory location of the access error. The erroneous memory block is determined by the address, and finally the code block with memory usage problem and the problem type can be determined according to the memory fingerprint in the header of the erroneous memory block, so that the memory usage problem can be quickly and accurately located based on the memory fingerprint, thereby improving the stability and reliability of the software; at the same time, the fingerprint-based memory tracking method does not depend on a specific operating system or programming language, has good portability, and can be implemented on multiple platforms. It can support different environments by adapting different memory allocators and programming language interfaces, can support a wider range of application scenarios and development environments, and is helpful to unify memory tracking solutions in cross-platform applications; in addition, the fingerprint-based memory tracking method can restore the location of the memory error based on the memory fingerprint only, and does not need to analyze each memory allocation and release operation, which helps to reduce operating overhead.
[0076] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.
[0077] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A fingerprint-based memory tracking method, characterized in that: include: Intercepting a memory allocation request, and generating a memory block size according to the number of requested memory bytes carried in the memory allocation request; Calling the original memory allocation function in the memory allocator to allocate the current memory block based on the memory block size; Storing a memory fingerprint in a header of the current memory block, the memory fingerprint including call stack information allocated to the current memory block, a memory block size of the current memory block, and a MagicNumber; When memory tracking is required, the erroneous memory block is determined based on the memory address of the access error, and the code block with memory usage problem and the problem type are determined based on the memory fingerprint in the header of the erroneous memory block.
2. The fingerprint-based memory tracking method according to claim 1, characterized in that: Storing a memory fingerprint in a header of the current memory block includes: At the head of the current memory block, before the original header information, use a preset number of bytes to store the memory fingerprint, store the call stack information, the memory block size of the current memory block and the MagicNumber in order from near to far from the original header information, and return the original header information to the user.
3. The fingerprint-based memory tracking method according to claim 2, characterized in that: Storing a memory fingerprint in a header of the current memory block includes: Calculate the hash value of the call stack information, determine whether the hash value has been stored in a static table, and if not, store the hash value in the static table, and store the hash value in the header of the current memory block, wherein the hash value of the call stack information is used as a key and the function address list of the call stack information is used as a value.
4. The fingerprint-based memory tracking method according to claim 3, characterized in that: Calculating the hash value of the call stack information includes: Calculate an initial hash value according to the function address list in the call stack information; The depth of the call stack is added to the initial hash value, and the final hash value is calculated again.
5. The fingerprint-based memory tracking method according to any one of claims 1 to 4, characterized in that: Determine the problem type of the memory usage problem according to the memory fingerprint in the header of the error memory block, including: In the header of the error memory block, scan along the memory address where the access error occurred to the lower address until MagicNumber is found; The number of bytes from the memory address of the access error to MagicNumber is calculated, and the problem type of the memory usage problem is determined according to the relationship between the number of bytes and the memory block size of the error memory block.
6. The fingerprint-based memory tracking method according to claim 5, characterized in that: Determining the problem type of the memory usage problem according to the relationship between the number of bytes and the memory block size of the erroneous memory block includes: If the number of bytes is greater than the memory block size of the erroneous memory block, the memory usage problem is determined to be an address out-of-bounds problem; if the number of bytes is less than the memory block size of the erroneous memory block, the memory usage problem is determined to be wild pointer usage.
7. The fingerprint-based memory tracking method according to any one of claims 1 to 4, characterized in that: Determining a code block having a memory usage problem according to the memory fingerprint in the header of the erroneous memory block includes: Determine a function address list of corresponding call stack information in a static table according to a hash value of the call stack information in the header of the error memory block; The function call relationship is restored according to the function address list of the call stack information, and the code block with memory usage problem is determined based on the function call relationship.
8. A fingerprint-based memory tracking device, characterized in that: include: An acquisition module, used for intercepting a memory allocation request and generating a memory block size according to the number of requested memory bytes carried in the memory allocation request; A memory allocation module, used for calling the original memory allocation function in the memory allocator to allocate the current memory block based on the memory block size; A fingerprint storage module, used to store a memory fingerprint in the header of the current memory block, wherein the memory fingerprint includes call stack information allocated to the current memory block, a memory block size of the current memory block, and a MagicNumber; The memory tracking module is used to determine the erroneous memory block according to the memory address of the access error when memory tracking is required, and determine the code block with memory usage problem and the problem type according to the memory fingerprint in the header of the erroneous memory block.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the fingerprint-based memory tracking method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the fingerprint-based memory tracking method according to any one of claims 1 to 7.