CN111984496B - Method, device, medium and electronic equipment for monitoring stack memory leakage - Google Patents

Method, device, medium and electronic equipment for monitoring stack memory leakage Download PDF

Info

Publication number
CN111984496B
CN111984496B CN202010686327.4A CN202010686327A CN111984496B CN 111984496 B CN111984496 B CN 111984496B CN 202010686327 A CN202010686327 A CN 202010686327A CN 111984496 B CN111984496 B CN 111984496B
Authority
CN
China
Prior art keywords
thread
exit
information
stack memory
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010686327.4A
Other languages
Chinese (zh)
Other versions
CN111984496A (en
Inventor
朴英敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010686327.4A priority Critical patent/CN111984496B/en
Publication of CN111984496A publication Critical patent/CN111984496A/en
Application granted granted Critical
Publication of CN111984496B publication Critical patent/CN111984496B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3037Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a memory, e.g. virtual memory, cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The disclosure provides a method, a device, a medium and electronic equipment for monitoring stack memory leakage. The method comprises the following steps: acquiring a current exit state in an instant exit function of which the first thread is hijacked; inquiring whether waiting exit information corresponding to the first thread exists in the current application or not when the current exit state is a connection state; and when the waiting exit information does not exist, determining that the stack memory of the first thread is leaked abnormally. The method and the device for monitoring the stack memory leakage condition of the thread in the instant exit function by hijacking the instant exit function, and prompting the stack memory leakage information when the processing mode of releasing the stack memory information does not accord with the grammar rule. The problem of unreasonable program writing leading to stack memory leakage and further application breakdown is solved.

Description

Method, device, medium and electronic equipment for monitoring stack memory leakage
Technical Field
The disclosure relates to the technical field of computers, and in particular relates to a method, a device, a medium and electronic equipment for monitoring stack memory leakage.
Background
In computer technology, tasks include various actions and corresponding response events of a user when the user operates the computer. For example, a mouse click, right click, open a dialog box, close a file, start a program. In summary, a task is a broad concept that is accomplished by a large number of processes interacting.
Threads, which are terms of operating system technology, are the smallest units that an operating system can schedule for operations, which are included in a process, and are the actual units of operation in the process. One thread is a single sequential control flow in a process, and multiple threads can be parallel in a process, and each thread can execute different tasks in parallel.
In the software development process, complex and heavy tasks are generally completed by one or more independent threads. So there is a correspondence between tasks and threads.
However, due to unreasonable application to threads, stack memory leaks are caused, ultimately resulting in program crashes. Such stack memory leakage problems are difficult to find in the crash field and thus are difficult to troubleshoot.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
The disclosure aims to provide a method, a device, a medium and an electronic device for monitoring stack memory leakage, which can solve at least one technical problem mentioned above. The specific scheme is as follows:
according to a specific embodiment of the present disclosure, in a first aspect, the present disclosure provides a method for monitoring stack memory leakage, including:
acquiring a current exit state in an instant exit function of which the first thread is hijacked;
inquiring whether waiting exit information corresponding to the first thread exists in the current application or not when the current exit state is a connection state;
and when the waiting exit information does not exist, determining that the stack memory of the first thread is leaked abnormally.
According to a second aspect of the present disclosure, there is provided an apparatus for monitoring stack memory leaks, including:
the acquisition unit is used for acquiring the current exit state in the hijacked instant exit function of the first thread;
the inquiring unit is used for inquiring whether waiting exit information corresponding to the first thread exists in the current application or not when the current exit state is a connection state;
and the determining unit is used for determining that the stack memory of the first thread is leaked abnormally when the waiting exit information does not exist.
According to a third aspect of the disclosure, there is provided a computer readable storage medium having stored thereon a computer program which when executed by a processor implements a method of monitoring stack memory leakage as claimed in any of the first aspects.
According to a fourth aspect of the present disclosure, there is provided an electronic device comprising: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement a method of monitoring stack memory leaks as claimed in any one of the first aspects.
Compared with the prior art, the scheme of the embodiment of the disclosure has at least the following beneficial effects:
the disclosure provides a method, a device, a medium and electronic equipment for monitoring stack memory leakage. The method and the device for monitoring the stack memory leakage condition of the thread in the instant exit function by hijacking the instant exit function, and prompting the stack memory leakage information when the processing mode of releasing the stack memory information does not accord with the grammar rule. The problem of unreasonable program writing leading to stack memory leakage and further application breakdown is solved.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale. In the drawings:
FIG. 1 illustrates a flow chart of a method of monitoring stack memory leaks according to an embodiment of the present disclosure;
FIG. 2 illustrates a block diagram of a unit of an apparatus for monitoring stack memory leaks according to an embodiment of the present disclosure;
fig. 3 illustrates a schematic diagram of an electronic device connection structure according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
Alternative embodiments of the present disclosure are described in detail below with reference to the drawings.
The first embodiment provided by the present disclosure is an embodiment of a method for monitoring stack memory leakage.
Embodiments of the present disclosure are described in detail below in conjunction with fig. 1.
Step S101, obtaining the current exit state in the hijacked instant exit function of the first thread.
Thread, which is a term in operating system technology, is the smallest unit that an operating system can perform operation scheduling, and is included in an application, and is the actual unit of operation in the application. One thread is a single sequential control flow in an application, and multiple threads can be parallel in an application, each thread executing different tasks in parallel.
The instant exit function is applied to threads, and functions to immediately exit the threads calling the instant exit function.
In a UNIX-like (UNIX, linux, android) operating system, the just-in-time exit function is denoted by pthread_exit, and the creation thread function is denoted by pthread_create. When a thread is created by applying the pthread_create function, a corresponding stack memory is also created for that thread in memory. Different ways of freeing the stack memory are required according to two different exit states. When the exiting state of the current application is a separation state (namely PTHREAD_CREATE_DETACHED), the corresponding stack memory can be released in the thread through a PTHREAD_exit function; when the exit state of the current application is the connected state (i.e., PTHREAD_CREATE_JOINABLE), the stack memory of the specified thread needs to be released by calling the wait exit function (i.e., PTHREAD_JOINE function) by other threads. The pthread_join function waits in a blocking manner for the specified thread to end. When the waiting thread returns, the stack memory of the waiting thread is retired by the pthread_join function. If the waiting thread has ended, the pthread_join function immediately reclaims the stack memory of the waiting thread.
However, many developers often neglect the application rules described above, resulting in stack memory leaks.
The embodiment of the disclosure hives the instant exit function through a hook technology so as to monitor whether stack memory leakage is safe or not.
The pthread_exit function is hijacked because it is a system function whose specific code is not open to the outside. Hijacking the pthread_exit function may be followed by adding functionality to the hijacking function that the developer wishes to add to the pthread_exit function. Embodiments of the present disclosure are directed to adding functionality to monitor stack memory leakage in a pthread_exit function.
The exit state includes a connected state and a disconnected state. The system defaults to the connected state, which can be set to the disconnected state by an exit state setting function (i.e., pthread_attr_setsetsetreach).
Step S102, inquiring whether waiting exit information corresponding to the first thread exists in the current application or not when the current exit state is a connection state.
Wait for exit information, i.e. information of whether there is a wait for exit function corresponding to the first thread in the current application.
Optionally, the querying whether the waiting exit information corresponding to the first thread exists in the current application includes the following steps:
step S102-1, obtaining unique thread identity information of the first thread.
That is, in the instant exit function where the first thread is hijacked, the unique thread identity information of the first thread is obtained. When threads are created, each thread obtains unique thread identity information to distinguish between the work of the different threads. In a UNIX-like operating system, the pthread_create function generates a unique thread identity after the thread is created. However, the pthread_exit function is executed in the current thread, and does not pass the unique thread identity information parameter of the current thread. The unique thread identity information of the current thread can be obtained by obtaining the current unique thread identity information function (namely, the pthread_self function) in the hijacking instant exit function.
Step S102-2, inquiring whether corresponding waiting exiting information exists in the exiting state information set of the current application or not based on the unique thread identity information.
The exit status information set may be: text files, configuration files, data tables, or spreadsheets. The exit state information set is used for storing information whether each thread in the application has a corresponding waiting exit function. Each record of the exit state information set includes unique thread identity information of the thread and wait for exit information of the corresponding thread. For example, in the exit status information set, the wait for exit information uses the character "Y" to indicate that there is a pthread_join function for the corresponding thread in the application.
Optionally, in order to acquire the exit state information set, before the current exit state is acquired, the method further includes the following steps:
step S100-1, in the hijacked waiting and exiting function, obtaining the unique thread identity information of the first thread from the output parameters of the creating thread function.
The pthread_join function is hijacked because it is a system function whose specific code is not open to the outside. Hijacking the pthread_join function may be followed by adding functionality to the hijacking function that the developer wishes to add to the pthread_join function. Embodiments of the present disclosure contemplate adding a monitoring function to the pthread_join function.
Since the pthread_join function is provided in other threads outside the first thread, unique thread identity information of the first thread cannot be obtained by the pthread_self function. However, the pthread_join function clears the stack memory of the first thread, and one of its input parameters is the unique thread identity information of the first thread. The input parameter value is derived from the output parameter of the pthread_create function. For example, the format of creating a thread function is: pthread_create (& tlid, NULL, first_thread, NULL); where first_thread represents the first thread and thread represents the unique thread identity information of the first thread.
And step S100-2, storing the unique thread identity information and the waiting for exit information into the exit state information set.
Each record of the exit state information set includes unique thread identity information of the thread and wait for exit information of the corresponding thread. For example, in the exit status information set, the wait for exit information uses the character "Y" to indicate that there is a pthread_join function for the corresponding thread in the application.
Optionally, after the current exit state is obtained, the method further includes the following steps:
step S102a, when the current exit state is a separate state, determining that the stack memory of the first thread is normal.
I.e. there is no leakage problem in the stack memory.
Step S103, when the waiting exit information does not exist, determining that the stack memory of the first thread is leaked abnormally.
The current exit state is a connected state, indicating that there should be a wait for exit function for the first thread in the programming. And when the waiting and exiting function is hijacked, corresponding waiting and exiting information is recorded. If the waiting exit information does not exist, determining that a waiting exit function corresponding to the first thread is not set in the program, and determining that the stack memory of the first thread leaks abnormally.
After the abnormal stack memory leakage of the first thread is determined, returning an error and alarming, and at least comprising the following alarming steps:
step S103a-1, acquiring and storing the stack memory information, and generating corresponding prompt information;
step S103b-1, forcedly exiting the current application;
step S103c-1, the exit status information set of the current application is printed.
And saving and prompting stack memory information so as to facilitate a developer to analyze stack memory leakage information.
The current application is forced to be exited, and the running of the current application can be immediately stopped, so that a developer is reminded of the problem of stack memory leakage in the program, and debugging is immediately started.
Printing the exit state information set of the current application is beneficial to helping a developer check the lost waiting exit function.
When the current exit state is a connection state, inquiring whether the waiting exit information corresponding to the first thread exists in the current application or not, and further comprising the following steps:
step S104, when the waiting exit information exists, determining that the stack memory of the first thread is normal and generating corresponding prompt information.
I.e. there is no leakage problem in the stack memory.
According to the embodiment of the disclosure, the instant exit function is hijacked, the stack memory leakage condition of the thread is monitored from the instant exit function, and when the processing mode of releasing the stack memory information does not accord with the grammar rule, the stack memory leakage information is prompted. The problem of unreasonable program writing leading to stack memory leakage and further application breakdown is solved.
Corresponding to the first embodiment provided by the present disclosure, the present disclosure also provides a second embodiment, i.e., an apparatus for monitoring stack memory leakage. Since the second embodiment is substantially similar to the first embodiment, the description is relatively simple, and the relevant portions will be referred to the corresponding descriptions of the first embodiment. The device embodiments described below are merely illustrative.
Fig. 2 illustrates an embodiment of an apparatus for monitoring stack memory leakage provided by the present disclosure.
Referring to fig. 2, the disclosure provides a device for monitoring stack memory leakage, including:
an obtaining unit 201, configured to obtain a current exit state in an immediate exit function where the first thread is hijacked;
a query unit 202, configured to query whether there is waiting for exit information corresponding to the first thread in the current application when the current exit state is a connection state;
a determining unit 203, configured to determine that the stack memory of the first thread leaks abnormally when the waiting exit information does not exist.
Optionally, in the querying unit 202, it includes:
a unique thread identity information obtaining subunit, configured to obtain unique thread identity information of the first thread;
and the inquiring waiting and exiting information subunit is used for inquiring whether corresponding waiting and exiting information exists in the exiting state information set of the current application or not based on the unique thread identity information.
Optionally, the apparatus further includes: a recording unit;
in the recording unit, it includes:
the output parameter obtaining subunit is used for obtaining the unique thread identity information of the first thread from the output parameters of the thread creating function in the hijacked waiting for exiting function before the current exiting state is obtained;
and the storage subunit is used for storing the unique thread identity information and the waiting for exit information into the exit state information set.
Optionally, the apparatus further includes:
and the first prompt normal unit is used for determining that the stack memory of the first thread is normal when the current exit state is a separation state after the current exit state is acquired.
Optionally, the apparatus further includes:
and the second prompt normal unit is used for determining that the stack memory of the first thread is normal and generating corresponding prompt information when the waiting exit information exists.
Optionally, the apparatus further includes:
and the stack memory information storage unit is used for acquiring and storing the stack memory information after the abnormal stack memory leakage of the first thread is determined, and generating corresponding prompt information.
Optionally, the apparatus further includes:
and the current application exiting unit is used for forcedly exiting the current application after the abnormal stack memory leakage of the first thread is determined.
According to the embodiment of the disclosure, the instant exit function is hijacked, the stack memory leakage condition of the thread is monitored from the instant exit function, and when the processing mode of releasing the stack memory information does not accord with the grammar rule, the stack memory leakage information is prompted. The problem of unreasonable program writing leading to stack memory leakage and further application breakdown is solved.
An embodiment of the present disclosure provides a third embodiment, namely an electronic device, where the method for monitoring stack memory leakage by using the electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the one processor to enable the at least one processor to perform the method of monitoring stack memory leaks as described in the first embodiment.
The fourth embodiment is a computer storage medium storing computer executable instructions for performing the method for monitoring stack memory leaks according to the first embodiment.
Referring now to fig. 3, a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 3 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 3, the electronic device may include a processing means (e.g., a central processor, a graphics processor, etc.) 301 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 302 or a program loaded from a storage means 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
In general, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 308 including, for example, magnetic tape, hard disk, etc.; and communication means 309. The communication means 309 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. While fig. 3 shows an electronic device having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via a communication device 309, or installed from a storage device 308, or installed from a ROM 302. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing means 301.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including, but not limited to, an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.

Claims (8)

1. A method for monitoring stack memory leaks, comprising:
acquiring a current exit state in an instant exit function of which the first thread is hijacked; the exit state is marked as a connection state or a separation state;
when the current exit state is a connection state, acquiring unique thread identity information of the first thread; inquiring whether waiting exit information corresponding to the first thread exists in the exit state information set of the current application based on the unique thread identity information; the method comprises the steps that an exit state information set is used for storing whether each thread in an application has information of a corresponding waiting exit function, and each record of the exit state information set comprises unique thread identity information of the thread and the waiting exit information of the corresponding thread; when the waiting exit information does not exist, determining that the stack memory of the first thread is abnormal in leakage;
and when the current exit state is a separation state, determining that the stack memory of the first thread is normal.
2. The method of claim 1, further comprising, prior to said acquiring the current exit state:
in the hijacked waiting and exiting function, acquiring unique thread identity information of the first thread from output parameters of a created thread function;
and storing the unique thread identity information and the waiting for exit information into the exit state information set.
3. The method of claim 1, further comprising, after querying whether there is waiting for exit information for the first thread in a current application when the current exit state is a connected state:
and when the waiting exit information exists, determining that the stack memory of the first thread is normal and generating corresponding prompt information.
4. The method of claim 1, further comprising, after said determining that the stack memory of the first thread leaks abnormally:
and acquiring and storing the stack memory information, and generating corresponding prompt information.
5. The method of claim 1, further comprising, after the determining that the stack memory leak of the first thread is abnormal, at least one of:
inquiring and printing an exit state information set of the current application based on the unique thread identity information;
outputting the stack memory information;
and forcedly exiting the current application.
6. An apparatus for monitoring stack memory leaks, comprising:
the acquisition unit is used for acquiring the current exit state in the hijacked instant exit function of the first thread; the exit state is marked as a connection state or a separation state;
the inquiring unit is used for inquiring whether waiting exit information corresponding to the first thread exists in the current application or not when the current exit state is a connection state; the method comprises the steps that an exit state information set is used for storing whether each thread in an application has information of a corresponding waiting exit function, and each record of the exit state information set comprises unique thread identity information of the thread and the waiting exit information of the corresponding thread;
a determining unit, configured to determine that, when the waiting exit information does not exist, a stack memory leakage of the first thread is abnormal; and when the current exit state is a separation state, determining that the stack memory of the first thread is normal.
7. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any one of claims 1 to 5.
8. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs which when executed by the one or more processors cause the one or more processors to implement the method of any of claims 1 to 5.
CN202010686327.4A 2020-07-16 2020-07-16 Method, device, medium and electronic equipment for monitoring stack memory leakage Active CN111984496B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010686327.4A CN111984496B (en) 2020-07-16 2020-07-16 Method, device, medium and electronic equipment for monitoring stack memory leakage

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010686327.4A CN111984496B (en) 2020-07-16 2020-07-16 Method, device, medium and electronic equipment for monitoring stack memory leakage

Publications (2)

Publication Number Publication Date
CN111984496A CN111984496A (en) 2020-11-24
CN111984496B true CN111984496B (en) 2024-04-16

Family

ID=73439248

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010686327.4A Active CN111984496B (en) 2020-07-16 2020-07-16 Method, device, medium and electronic equipment for monitoring stack memory leakage

Country Status (1)

Country Link
CN (1) CN111984496B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342431B (en) * 2021-06-29 2023-02-07 苏州科达科技股份有限公司 Function call stack backtracking and program exception handling method, device, equipment and medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763305A (en) * 2009-12-29 2010-06-30 青岛海信宽带多媒体技术有限公司 Method for detecting memory leak of embedded system
CN101908018A (en) * 2010-07-20 2010-12-08 北京海泰方圆科技有限公司 System and method for judging memory leak
CN103404082A (en) * 2011-03-15 2013-11-20 欧姆龙株式会社 Connection abnormality detection method, network system, and master device
CN106502880A (en) * 2016-09-20 2017-03-15 东软集团股份有限公司 A kind of memory overflow adjustment method and device
CN106802861A (en) * 2015-11-26 2017-06-06 大唐移动通信设备有限公司 A kind of method and apparatus for detecting RAM leakage
CN109918897A (en) * 2019-02-27 2019-06-21 苏州浪潮智能科技有限公司 A kind of password authentification test method and system based on AEP memory
CN110633190A (en) * 2019-09-26 2019-12-31 北京博睿宏远数据科技股份有限公司 Application program memory monitoring method, device, equipment and storage medium
CN110704217A (en) * 2019-08-27 2020-01-17 努比亚技术有限公司 Memory leak detection method, terminal and computer readable storage medium
CN111090536A (en) * 2019-11-19 2020-05-01 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for acquiring memory leakage information

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763305A (en) * 2009-12-29 2010-06-30 青岛海信宽带多媒体技术有限公司 Method for detecting memory leak of embedded system
CN101908018A (en) * 2010-07-20 2010-12-08 北京海泰方圆科技有限公司 System and method for judging memory leak
CN103404082A (en) * 2011-03-15 2013-11-20 欧姆龙株式会社 Connection abnormality detection method, network system, and master device
CN106802861A (en) * 2015-11-26 2017-06-06 大唐移动通信设备有限公司 A kind of method and apparatus for detecting RAM leakage
CN106502880A (en) * 2016-09-20 2017-03-15 东软集团股份有限公司 A kind of memory overflow adjustment method and device
CN109918897A (en) * 2019-02-27 2019-06-21 苏州浪潮智能科技有限公司 A kind of password authentification test method and system based on AEP memory
CN110704217A (en) * 2019-08-27 2020-01-17 努比亚技术有限公司 Memory leak detection method, terminal and computer readable storage medium
CN110633190A (en) * 2019-09-26 2019-12-31 北京博睿宏远数据科技股份有限公司 Application program memory monitoring method, device, equipment and storage medium
CN111090536A (en) * 2019-11-19 2020-05-01 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for acquiring memory leakage information

Also Published As

Publication number Publication date
CN111984496A (en) 2020-11-24

Similar Documents

Publication Publication Date Title
CN111090536B (en) Method, device, medium and electronic equipment for acquiring memory leakage information
CN110727566B (en) Method, device, medium and electronic equipment for acquiring process crash information
CN111679990B (en) Test data generation method and device, readable medium and electronic equipment
CN113835992B (en) Memory leakage processing method and device, electronic equipment and computer storage medium
CN110377341B (en) Method, device, medium and electronic equipment for monitoring no-response exception
CN111625422B (en) Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium
CN112817831A (en) Application performance monitoring method, device, computer system and readable storage medium
CN111984496B (en) Method, device, medium and electronic equipment for monitoring stack memory leakage
CN112084024B (en) Memory monitoring method, device, medium and electronic equipment
CN110764995B (en) Method, device, medium and electronic equipment for detecting file access abnormality
CN112379967B (en) Simulator detection method, device, equipment and medium
CN112882921B (en) Fault simulation method and device
CN112506781B (en) Test monitoring method, device, electronic equipment, storage medium and program product
CN113448585B (en) Compiling method and device of thread pool, electronic equipment and storage medium
CN109960659B (en) Method and device for detecting application program
CN114064376A (en) Page monitoring method and device, electronic equipment and medium
CN112905167B (en) Application operation method and device and electronic equipment
CN115827415B (en) System process performance test method, device, equipment and computer medium
CN113127051B (en) Application resource packaging process monitoring method, device, equipment and medium
CN111324888B (en) Verification method and device for application program starting, electronic equipment and storage medium
CN116149822A (en) Task execution method, device, electronic equipment and storage medium
CN117992204A (en) Memory detection method, device, equipment and storage medium
CN116501597A (en) Code detection method, device, equipment and storage medium
CN116302142A (en) Lifecycle event management method, lifecycle event management device, storage medium, and electronic apparatus
CN118093405A (en) Method and device for generating mobile terminal test case, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant