CN115994042A - Program exception handling method and device, electronic equipment and storage medium - Google Patents

Program exception handling method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115994042A
CN115994042A CN202111222436.1A CN202111222436A CN115994042A CN 115994042 A CN115994042 A CN 115994042A CN 202111222436 A CN202111222436 A CN 202111222436A CN 115994042 A CN115994042 A CN 115994042A
Authority
CN
China
Prior art keywords
exception
exception handling
module
processing
information
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.)
Pending
Application number
CN202111222436.1A
Other languages
Chinese (zh)
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 Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Wuhan Kingsoft Office Software Co Ltd
Original Assignee
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Wuhan Kingsoft Office Software 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 Kingsoft Office Software Inc, Zhuhai Kingsoft Office Software Co Ltd, Wuhan Kingsoft Office Software Co Ltd filed Critical Beijing Kingsoft Office Software Inc
Priority to CN202111222436.1A priority Critical patent/CN115994042A/en
Publication of CN115994042A publication Critical patent/CN115994042A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a program exception handling method, a program exception handling device, electronic equipment and a storage medium. The method comprises the following steps: hooking a first function of an operating system, wherein the first function is a function for executing an abnormal event distribution operation of the operating system at an application layer; calling a second function to monitor the abnormal event and acquiring abnormal processing information corresponding to the abnormal event; and sending the exception handling information to each module, performing pre-processing by each module according to the exception handling information, and executing repairing operation on the exception event through the pre-processing. The invention realizes the exception handling of multiple modules in the same process, and provides a more effective way for exception repair and exception filtering.

Description

Program exception handling method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and apparatus for processing program exception, an electronic device, and a storage medium.
Background
In a computer network, when an exception occurs in a program, an exception handling mechanism of an operating system application layer can enable a computer to handle an exception event generated during the running of the program, for example, in a processing manner including performing exception repair processing, generating an exception report, and the like.
In the prior art, after an exception event is repaired by the top-level exception handler, if the repair is not completed, the program will crash. And when the top-level exception handler is called, it can only perform exception handling on one module, so that the exception handling efficiency of the computer is greatly limited.
Disclosure of Invention
The invention provides a program exception handling method, a program exception handling device, electronic equipment and a storage medium, so as to realize exception handling of a plurality of modules in the same process.
The invention provides a program exception handling method, which comprises the following steps:
hooking a first function of an operating system, wherein the first function is a function for executing an abnormal event distribution operation of the operating system at an application layer;
calling a second function to monitor the abnormal event and acquiring abnormal processing information corresponding to the abnormal event;
and sending the exception handling information to each module, performing pre-processing by each module according to the exception handling information, and executing repairing operation on the exception event through the pre-processing.
Optionally, before the hooking the first function of the operating system, the method further includes:
creating an abnormal function table;
and under the condition that the module is loaded, inserting a first exception handling function corresponding to the module into the exception function table.
Optionally, the sending the exception handling information to each module, where each module performs a pre-processing according to the exception handling information, and performs a repair operation on the exception event through the pre-processing, where the performing includes:
calling the first exception handling function and sending the exception handling information to the first exception handling function;
and the first exception handling function performs corresponding exception repairing processing according to the first association degree of the exception handling information and the module.
Optionally, the first exception handling function performs corresponding exception repair processing according to the first association degree of the exception handling information and the module, including:
generating a first abnormality repair instruction under the condition that the abnormality processing information is generated by the module, and executing module abnormality repair operation according to the first abnormality repair instruction;
and generating a second exception repairing instruction under the condition that the exception handling information is not generated by the module, and executing a module exception neglecting operation according to the second exception repairing instruction.
Optionally, after each module performs pre-processing according to the exception handling information, the method further includes:
the exception handling information is sent to each module, and each module carries out post-processing according to the exception handling information;
determining an unrepaired abnormal event according to the post-processing, and acquiring the abnormal processing information of the unrepaired abnormal event;
and generating a report or terminating the application program according to the abnormal processing information of the unrepaired abnormal event.
Optionally, the exception handling information is sent to each module, and each module performs post-processing according to the exception handling information, including:
calling a second exception handling function, and sending the exception handling information to the second exception handling function;
and the second exception handling function performs corresponding re-exception repair processing according to the second association degree of the exception handling information and the module.
Optionally, the sending the exception handling information to each module, and before each module performs post-processing according to the exception handling information, the method further includes:
and sending the exception handling information to each module, and performing top layer processing by each module according to the exception handling information.
Optionally, the method further comprises:
in the case where the abnormal event has been repaired in the pre-processing, or in the case where the abnormal event has been repaired in the post-processing, or in the case where the abnormal event has been repaired in the top-level processing, an abnormal repaired information notification is returned to the second function.
Optionally, the sending the exception handling information to each module, and before each module performs pre-processing according to the exception handling information, the method further includes:
judging whether the abnormal event is possibly repaired;
in the case that the abnormal event is possibly repaired, sending the abnormal processing information to each module to perform the pre-processing;
in the event that the exception event is unlikely to be repaired, the first function of the operating system is tuned back.
Optionally, before each module performs pre-processing according to the exception handling information, the method further includes:
and each module performs vectorization exception processing according to the exception processing information, and/or each module performs structured exception processing according to the exception processing information.
Optionally, the method further comprises:
the exception handling information includes memory address information and exception occurrence cause information.
The invention also provides a program exception handling device, comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for hooking a first function of an operating system, wherein the first function is a function for executing abnormal event distribution operation of the operating system at an application layer;
the calling module is used for calling a second function to monitor the abnormal event and acquiring the abnormal processing information corresponding to the abnormal event;
and the pre-processing module is used for sending the exception handling information to each module, each module carries out pre-processing according to the exception handling information, and the repairing operation is carried out on the exception event through the pre-processing.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of any one of the program exception handling methods described above when executing the program.
The present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the program exception handling method as described in any of the above.
According to the program exception handling method, the device, the electronic equipment and the storage medium, the first function of the operating system is hooked, wherein the first function is a function for executing exception event distribution operation of the operating system at an application layer, then a second function is called to monitor the exception event, exception handling information corresponding to the exception event is obtained, the exception handling information is sent to each module, each module performs pre-processing according to the exception handling information, and repairing operation is executed on the exception event through the pre-processing. Therefore, the invention can monitor the abnormal event by calling the second function and send the abnormal processing information corresponding to the abnormal event to each module, so that each module can pre-process the abnormal event according to the received abnormal processing information, the multi-module can capture the abnormal event together and repair the abnormal event, the limitation that the prior art can only carry out abnormal capture and abnormal repair on a single module is eliminated, and the abnormal processing efficiency of the computer is greatly improved.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a program exception handling method provided by the present invention;
FIG. 2 is a schematic diagram of a program exception handling apparatus according to the present invention;
fig. 3 is a schematic structural diagram of an electronic device provided by the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The program exception handling method provided by the invention is suitable for various operating systems, for example, suitable systems can be Windows operating systems, unix operating systems, linux operating systems and Mac operating systems. The terminal device related to the invention can be computer equipment used in mobile, and broadly includes mobile phones, notebooks, POS machines and even vehicle-mounted computers, and is not particularly limited herein.
The program exception handling method of the present invention is described below with reference to fig. 1, 2 and 3. As shown in fig. 1, the program exception handling method provided by the present invention includes:
step 101: hooking a first function of an operating system, wherein the first function is a function for executing an abnormal event distribution operation of the operating system at an application layer;
in this step, the first function of the operating system (the unprocessed exception filter function Unhandled Exception Filter) is hooked, and the first function of the operating system refers to hooking the first function (the function that performs the exception event distribution operation of the operating system at the application layer) in the operating system, so that the operating system will automatically call the callback function to perform the operation desired by the operator. Wherein exception distribution refers to the distribution of exceptions by an operating system to a debugger or processing function of an application.
Step 102: calling a second function to monitor an abnormal event and acquiring abnormal processing information corresponding to the abnormal event;
in this step, a second function (tangent function Detour) is called to monitor an abnormal event, and when the abnormal event occurs, the abnormal processing information (abnormal pointer) corresponding to the abnormal event is acquired.
Step 103: and sending the exception handling information to each module, performing pre-processing by each module according to the exception handling information, and executing repairing operation on the exception event through the pre-processing.
In this step, the exception handling information is sent to each module, so that before the top-level exception handler is invoked, the exception is pre-handled by a plurality of modules, and if the exception is repaired in the pre-processing, the top-level exception handler does not need to be invoked.
In this step, it should be noted that the exception handling information is sent to each module one by one, that is, the exception handling information is to be sent to each module, that is, a one-to-many sending operation, so that each module performs a pre-processing according to the received exception handling information, and further performs a repairing operation on the exception event through the pre-processing.
According to the exception handling method, the first function of the operating system is hooked, wherein the first function is a function for executing exception event distribution operation of the operating system at an application layer, then a second function is called to monitor exception events, exception handling information corresponding to the exception events is obtained, the exception handling information is sent to each module, each module carries out pre-processing according to the exception handling information, and repairing operation is carried out on the exception events through the pre-processing. Therefore, the invention can monitor the abnormal event by calling the second function and send the abnormal processing information corresponding to the abnormal event to each module, so that each module can pre-process the abnormal event according to the received abnormal processing information, the multi-module can capture the abnormal event together and repair the abnormal event, the limitation that the prior art can only carry out abnormal capture and abnormal repair on a single module is eliminated, and the abnormal processing efficiency of the computer is greatly improved.
Based on the content of the foregoing embodiment, in this embodiment, before hooking the first function, the method further includes:
creating an abnormal function table;
and under the condition that the module is loaded, inserting a first exception handling function corresponding to the module into an exception function table.
In this embodiment, the exception function table is used to record a call function of the operating system when exception processing is performed. The first exception handling functions corresponding to the modules are exception handling functions in each module, the exception handling functions are different, and the capability of handling exception events is different. Before hooking Unhandled Exception Filter functions, judging whether an operating system establishes an exception function table (a modularized exception distribution function table), if not, firstly establishing the modularized exception distribution function table, and inserting exception processing functions corresponding to all modules into the modularized exception distribution function table. If the dynamic link library module DLL (Dynamic Link Library) is the dynamic link library module, the exception handling function corresponding to each module is inserted into the table tail of the modularized exception distribution function table. If the program module EXE (EXE File) is the executable program module EXE, the exception processing function corresponding to each module is inserted into the table head of the modularized exception distribution function table. Because the clearing of an EXE module from memory typically means a complete exit of the process (application), the life cycle of the EXE in memory is the life cycle of the process, and thus, in order to avoid unnecessary performance loss, the functions of the EXE module are inserted into the header. Where function insertion is the concept of replacing calls to functions in a dynamic library with calls to user-defined wrappers.
In this embodiment, a plurality of modules share one exception distribution function table, and each module is provided with an exception handler of the corresponding module itself. An exception handler includes an exception handling function.
Based on the content of the above embodiment, in the present embodiment, the exception handling information is sent to each module, each module performs a pre-process according to the exception handling information, and a repair operation is performed on an exception event by the pre-process, including:
calling a first exception handling function and sending exception handling information to the first exception handling function;
and the first exception handling function performs corresponding exception repairing processing according to the first association degree of the exception handling information and the module.
In this embodiment, current exception handling information is sequentially transferred to the exception handling functions corresponding to each module in the modularized exception distribution function table, and tolerance measures are taken for exceptions by the exception handling functions of each module according to the current exception handling information, that is, the modules may or may not handle the exceptions. Specifically, after the module receives the exception handling information, the module first judges the association degree of the exception information and the module itself, so that whether the module has the capability of repairing the exception or not can be understood, and if the module does not handle the exception, the module transfers the exception to the next flow. The exception handling method provided by the invention can be used for carrying out pre-processing on the exception by a plurality of modules before the top-level exception handler is called, and the top-level exception handler is not required to be called if the exception is repaired in the pre-processing, so that the problem that in the prior art, the exception handling can only be carried out in a single module is solved, the exception handling of a plurality of modules in the same process is realized, a more effective way is provided for exception repair and exception filtering, and the exception handling capability of a computer is improved.
Based on the foregoing embodiment, in this embodiment, the first exception handling function performs corresponding exception repair processing according to a first association degree of exception handling information and a module, including:
under the condition that the abnormality processing information is generated by the module, generating a first abnormality repair instruction, and executing the abnormality repair operation of the module according to the first abnormality repair instruction;
and generating a second abnormality repair instruction under the condition that the abnormality processing information is not generated by the module, and executing the module abnormality neglecting operation according to the second abnormality repair instruction.
In this embodiment, it should be noted that, each module may generate a corresponding exception handling instruction according to the exception handling information, where the exception handling instruction is used for the module to execute a module to repair an exception operation, or execute the module to ignore the exception operation, where the module exception ignore operation may be understood that the current module does not process an exception event. When the module is repaired after the module is operated to repair the abnormal operation, the subsequent steps are not performed any more, the repaired information of the abnormal operation is directly returned to the second function, and if the abnormal operation is not repaired or the module is operated to ignore the abnormal operation, the current abnormal operation is filtered, and the abnormal processing information is distributed to the next flow.
Based on the foregoing embodiment, in this embodiment, after each module performs the pre-processing according to the exception handling information, the method further includes:
the exception handling information is sent to each module, and each module carries out post-processing according to the exception handling information;
determining unrepaired abnormal events according to post-processing, and acquiring abnormal processing information of the unrepaired abnormal events;
and generating a report or terminating the application program according to the abnormal processing information of the unrepaired abnormal event.
In this embodiment, it should be noted that, after the module performs the pre-processing according to the exception handling information, the pre-processing unrepaired exception and/or the exception ignored by the pre-processing are obtained through filtering, then the top-level exception handler is called, the exception is repaired again according to the exception handling function corresponding to the top-level exception handler, if the exception is repaired, the information that the exception has been repaired is returned to the second function, if the exception has not been repaired, the unrepaired exception in the top-level processing is sent to each module, so that each module performs the post-processing according to the exception handling information, and determines the exception that may cause program crash. It should be noted that, the exception filtered by the top-level exception handler may cause a program crash, so after the current exception pointer is transferred to each module, each module retains the exception that causes the program crash, and uploads to the system to generate an error report or terminate the application program, so as to inhibit the operating system from reporting the "crash" behavior to the user, and realize silent exit. It should be noted that exceptions that the top level exception handler fails to repair are typically catastrophic, but this does not mean that the code of the application program is not able to continue to function properly at all, and some specially constructed code may still be run when the program is about to "crash". The exact meaning of "crash" is that the operating system, upon detecting an irreparable exception to the application, hangs the application, notifies the user and terminates the application's behavior.
Based on the content of the above embodiment, in this embodiment, the exception handling information is sent to each module, and each module performs post-processing according to the exception handling information, including:
calling a second exception handling function, and sending exception handling information to the second exception handling function;
and the second exception handling function performs corresponding re-exception repair processing according to the second association degree of the exception handling information and the module.
In this embodiment, the second exception handling function refers to a handling function corresponding to each module, exception handling information is sent to the exception handling function of each module, association degree between the exception handling information and itself is determined by the exception handling function of each module, and exception repair processing is performed again.
In this embodiment, the post-processing may optionally include generating an error report according to the exception handling information, and performing vectorized exception continuing processing according to the error report. Vectorized exception continued processing corresponds to a continued processor from which deterministic work is made after the exception has been processed through the above-described flow.
Based on the foregoing embodiment, in this embodiment, the method further includes, before sending the exception handling information to each module and performing post-processing according to the exception handling information by each module:
and sending the exception handling information to each module, and performing top layer processing by each module according to the exception handling information.
Based on the content of the above-described embodiment, in the present embodiment, in the case where an abnormal event has been repaired in the pre-processing, or in the case where an abnormal event has been repaired in the post-processing, or in the case where an abnormal event has been repaired in the top-level processing, an abnormal repaired information notification is returned to the second function.
Based on the foregoing embodiment, in this embodiment, the exception handling information is sent to each module, and before each module performs the pre-processing according to the exception handling information, the method further includes:
judging whether the abnormal event is possibly repaired;
under the condition that the abnormal event is possibly repaired, the abnormal processing information is sent to each module to carry out pre-processing;
in the event that the exception event cannot be repaired, the first function of the operating system is recalled.
In this embodiment, optionally, the case that the exception belongs to unrepairable includes: the exception is currently being one or more of nested, an exception due to a resource transformation, and an exception due to a deadlock. When any one of the conditions occurs, the exception cannot be processed through the subsequent steps, at this time, the exception processing information is not sent to each module any more, and the Unhandled Exception Filter function is directly called. Specifically, the following operations are performed in the second function:
a) If the exception is being nested, no further steps are performed, directly returning to the Unhandled Exception Filter function;
b) If the resource conversion causes the exception, the subsequent steps are not executed any more, and the method directly returns to the Unhandled Exception Filter function;
c) If the exception is caused by the deadlock, no subsequent steps are executed, and the method directly returns to the Unhandled Exception Filter function;
d) Calling functions in the modularized exception distribution function table one by one, transmitting current exception pointers to the functions, and performing pre-filtering;
e) Calling a top layer exception handler;
f) Calling functions in the modularized exception distribution function table one by one, transmitting current exception pointers to the functions, and performing post-filtering;
g) If the result of either step d) or e) indicates that the EXCEPTION has been repaired (an EXCEPTION has been identified as returned to the exception_context_exception), then no further steps are performed, and the exception_context_exception is returned directly (to the caller-the EXCEPTION has been repaired).
The exception nested finger function also has an exception handler, which may cause nesting exception, and the exception instruction caused by resource conversion is that the compiler automatically converts the class when running the program, and deadlock refers to a blocking phenomenon caused by competing resources or communicating with each other in the execution process of two or more processes, and if no external force acts, the two or more processes cannot be advanced.
Based on the foregoing embodiment, in this embodiment, before each module performs the pre-processing according to the exception handling information, the method further includes:
and each module performs vectorized exception handling according to the exception handling information, and/or each module performs structured exception handling according to the exception handling information.
Based on the contents of the above embodiments, in the present embodiment, the exception handling information includes the memory address information and the exception occurrence cause information.
The following is a description of specific examples:
first embodiment:
in this embodiment, the exception handling information needs to undergo pre-processing, top-level processing and post-processing, after the post-processing is completed, an exception event which is not repaired and is about to cause program crash is determined, and a corresponding error report is generated according to the exception event, so that a related technician performs subsequent processing according to the error report.
Second embodiment:
in this embodiment, after the exception handling information is pre-processed, the exception handling information which is not yet repaired is filtered out first, then the exception handling information is sent to a top layer exception handler for top layer processing, after the top layer processing is completed, the exception handling information which is not yet repaired is confirmed again, and the exception handling information is sent to each module for post-processing, after the post-processing is completed, an exception event which is not yet repaired finally and causes program crash is determined, and a corresponding error report is generated according to the exception event, so that relevant technicians can perform subsequent processing according to the error report.
Alternatively, the pre-processing and the post-processing may be set alternatively, that is, the pre-processing may be set alone, or the post-processing may be set alone, which is not particularly limited herein. Under the condition that only the pre-processing is set, determining an abnormal event which is not repaired finally and causes program crash after the top-level processing, and generating a corresponding error report. In the case of setting only the post-processing, after the post-processing is completed, an abnormal event which is not repaired finally and causes program crash is determined, and a corresponding error report is generated.
The program exception handling apparatus provided by the present invention will be described below, and the program exception handling apparatus described below and the program exception handling method described above may be referred to correspondingly to each other.
As shown in fig. 2, the exception handling apparatus provided by the present invention includes:
the system comprises an acquisition module 1, a processing module and a processing module, wherein the acquisition module 1 is used for hooking a first function of an operating system, wherein the first function is a function for executing abnormal event distribution operation of the operating system at an application layer;
the calling module 2 is used for calling a second function to monitor an abnormal event and acquiring abnormal processing information corresponding to the abnormal event;
and the pre-processing module 3 is used for sending the exception handling information to each module, and each module carries out pre-processing according to the exception handling information and executes repairing operation on the exception event through the pre-processing.
Based on the foregoing embodiment, in this embodiment, the obtaining module is further specifically configured to, before hooking the first function of the operating system:
creating an abnormal function table;
and under the condition that the module is loaded, inserting a first exception handling function corresponding to the module into an exception function table.
Based on the foregoing embodiments, in this embodiment, the pre-processing module is specifically configured to:
calling a first exception handling function and sending exception handling information to the first exception handling function;
and the first exception handling function performs corresponding exception repairing processing according to the first association degree of the exception handling information and the module.
Based on the foregoing embodiments, in this embodiment, the pre-processing module is specifically configured to:
under the condition that the abnormality processing information is generated by the module, generating a first abnormality repair instruction, and executing the abnormality repair operation of the module according to the first abnormality repair instruction;
and generating a second abnormality repair instruction under the condition that the abnormality processing information is not generated by the module, and executing the module abnormality neglecting operation according to the second abnormality repair instruction.
Based on the foregoing embodiments, in this embodiment, the pre-processing module is specifically configured to:
the exception handling information is sent to each module, and each module carries out post-processing according to the exception handling information;
determining unrepaired abnormal events according to post-processing, and acquiring abnormal processing information of the unrepaired abnormal events;
and generating a report or terminating the application program according to the abnormal processing information of the unrepaired abnormal event.
Based on the foregoing embodiments, in this embodiment, the pre-processing module is specifically configured to:
calling a second exception handling function, and sending exception handling information to the second exception handling function;
and the second exception handling function performs corresponding re-exception repair processing according to the second association degree of the exception handling information and the module.
Based on the foregoing embodiments, in this embodiment, the pre-processing module is specifically configured to:
and sending the exception handling information to each module, and performing top layer processing by each module according to the exception handling information.
Based on the foregoing embodiments, in this embodiment, the pre-processing module is specifically configured to:
in the case where the abnormal event has been repaired in the pre-processing, or in the case where the abnormal event has been repaired in the post-processing, or in the case where the abnormal event has been repaired in the top-level processing, an abnormal repaired information notification is returned to the second function.
Based on the foregoing embodiments, in this embodiment, the pre-processing module is specifically configured to, before sending the exception handling information to each module:
judging whether the abnormal event is possibly repaired;
under the condition that the abnormal event is possibly repaired, the abnormal processing information is sent to each module to carry out pre-processing;
in the event that the exception event cannot be repaired, the first function of the operating system is recalled.
Based on the foregoing embodiments, in this embodiment, the pre-processing module is specifically configured to, before sending the exception handling information to each module:
and each module performs vectorized exception handling according to the exception handling information, and/or each module performs structured exception handling according to the exception handling information.
Based on the contents of the above embodiments, in the present embodiment, the exception handling information includes the memory address information and the exception occurrence cause information.
Fig. 3 illustrates a physical schematic diagram of an electronic device, as shown in fig. 3, where the electronic device may include: processor 310, communication interface (Communications Interface) 320, memory 330 and communication bus 340, wherein processor 310, communication interface 320, memory 330 accomplish communication with each other through communication bus 340. Processor 310 may invoke logic instructions in memory 330, an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the program exception handling method according to any of claims 1 to 11 to perform the program exception handling method when the processor executes the program, the method comprising: hooking a first function of an operating system, wherein the first function is a function for executing abnormal event distribution operation of the operating system at an application layer; calling a second function to monitor the abnormal event and acquiring abnormal processing information corresponding to the abnormal event; and sending the exception handling information to each module, performing pre-processing by each module according to the exception handling information, and executing repairing operation on the exception event through the pre-processing.
Further, the logic instructions in the memory 330 described above may be implemented in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method of the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, where the computer program product includes a computer program, where the computer program may be stored on a non-transitory computer readable storage medium, and when the computer program is executed by a processor, the computer is capable of executing a program exception handling method provided by the above methods, where the method includes: hooking a first function of an operating system, wherein the first function is a function for executing an abnormal event distribution operation of the operating system at an application layer; calling a second function to monitor an abnormal event and acquiring abnormal processing information corresponding to the abnormal event; and sending the exception handling information to each module, performing pre-processing by each module according to the exception handling information, and executing repairing operation on the exception event through the pre-processing.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, is implemented to perform the program exception handling method provided by the above methods, the method comprising: hooking a first function of an operating system, wherein the first function is a function for executing an abnormal event distribution operation of the operating system at an application layer; calling a second function to monitor an abnormal event and acquiring abnormal processing information corresponding to the abnormal event; and sending the exception handling information to each module, performing pre-processing by each module according to the exception handling information, and executing repairing operation on the exception event through the pre-processing.
The apparatus embodiments described above are merely illustrative, wherein elements illustrated as separate elements may or may not be physically separate, and elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (14)

1. A program exception handling method, the method comprising:
hooking a first function of an operating system, wherein the first function is a function for executing an abnormal event distribution operation of the operating system at an application layer;
calling a second function to monitor the abnormal event and acquiring abnormal processing information corresponding to the abnormal event;
and sending the exception handling information to each module, performing pre-processing by each module according to the exception handling information, and executing repairing operation on the exception event through the pre-processing.
2. The method of program exception handling according to claim 1, wherein prior to the hooking the first function of the operating system, the method further comprises:
creating an abnormal function table;
and under the condition that the module is loaded, inserting a first exception handling function corresponding to the module into the exception function table.
3. The program exception handling method according to claim 2, wherein said sending the exception handling information to each module, each module performing a pre-process according to the exception handling information, and performing a repair operation on the exception event by the pre-process, comprises:
calling the first exception handling function and sending the exception handling information to the first exception handling function;
and the first exception handling function performs corresponding exception repairing processing according to the first association degree of the exception handling information and the module.
4. A program exception handling method according to claim 3, wherein said first exception handling function performs corresponding exception repair handling according to a first degree of association of said exception handling information with said module, comprising:
generating a first abnormality repair instruction under the condition that the abnormality processing information is generated by the module, and executing module abnormality repair operation according to the first abnormality repair instruction;
and generating a second exception repairing instruction under the condition that the exception handling information is not generated by the module, and executing a module exception neglecting operation according to the second exception repairing instruction.
5. The program exception handling method according to claim 4, wherein after said each module performs a pre-process according to said exception handling information, said method further comprises:
the exception handling information is sent to each module, and each module carries out post-processing according to the exception handling information;
determining an unrepaired abnormal event according to the post-processing, and acquiring the abnormal processing information of the unrepaired abnormal event;
and generating a report or terminating the application program according to the abnormal processing information of the unrepaired abnormal event.
6. The program exception handling method according to claim 5, wherein sending the exception handling information to each module, each module performing post-processing according to the exception handling information, comprises:
calling a second exception handling function, and sending the exception handling information to the second exception handling function;
and the second exception handling function performs corresponding re-exception repair processing according to the second association degree of the exception handling information and the module.
7. The program exception handling method according to claim 5, wherein said sending said exception handling information to respective modules, each module before post-processing according to said exception handling information, said method further comprising:
and sending the exception handling information to each module, and performing top layer processing by each module according to the exception handling information.
8. The program exception handling method according to claim 7, wherein the method further comprises:
in the case where the abnormal event has been repaired in the pre-processing, or in the case where the abnormal event has been repaired in the post-processing, or in the case where the abnormal event has been repaired in the top-level processing, an abnormal repaired information notification is returned to the second function.
9. The program exception handling method according to claim 1, wherein said sending the exception handling information to respective modules, each module being before performing a pre-process according to the exception handling information, the method further comprising:
judging whether the abnormal event is possibly repaired;
in the case that the abnormal event is possibly repaired, sending the abnormal processing information to each module to perform the pre-processing;
in the event that the exception event is unlikely to be repaired, the first function of the operating system is tuned back.
10. The program exception handling method according to claim 1, wherein before each module performs preprocessing according to the exception handling information, the method further comprises:
and each module performs vectorization exception processing according to the exception processing information, and/or each module performs structured exception processing according to the exception processing information.
11. The program exception handling method according to any one of claims 1 to 10, wherein the method further comprises:
the exception handling information includes memory address information and exception occurrence cause information.
12. A program exception handling apparatus, the apparatus comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for hooking a first function of an operating system, wherein the first function is a function for executing abnormal event distribution operation of the operating system at an application layer;
the calling module is used for calling a second function to monitor the abnormal event and acquiring the abnormal processing information corresponding to the abnormal event;
and the pre-processing module is used for sending the exception handling information to each module, each module carries out pre-processing according to the exception handling information, and the repairing operation is carried out on the exception event through the pre-processing.
13. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the program exception handling method according to any one of claims 1 to 11 when the program is executed by the processor.
14. A computer-readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the program exception handling method according to any one of claims 1 to 11.
CN202111222436.1A 2021-10-20 2021-10-20 Program exception handling method and device, electronic equipment and storage medium Pending CN115994042A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111222436.1A CN115994042A (en) 2021-10-20 2021-10-20 Program exception handling method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111222436.1A CN115994042A (en) 2021-10-20 2021-10-20 Program exception handling method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115994042A true CN115994042A (en) 2023-04-21

Family

ID=85989243

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111222436.1A Pending CN115994042A (en) 2021-10-20 2021-10-20 Program exception handling method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115994042A (en)

Similar Documents

Publication Publication Date Title
CN109144873B (en) Linux kernel processing method and device
CN111240812B (en) Task execution method and device
CN107888446A (en) A kind of agreement robustness testing method and device
CN112134754A (en) Pressure testing method and device, network equipment and storage medium
CN116302989A (en) Pressure testing method and system, storage medium and computer equipment
CN111181777B (en) Service degradation method, device, computer equipment and storage medium
CN112596938A (en) Abnormity monitoring method and device
CN115994042A (en) Program exception handling method and device, electronic equipment and storage medium
CN112817883A (en) Method, device and system for adapting interface platform and computer readable storage medium
CN106204031B (en) Card application processing method and device
CN111651350A (en) Test case processing method, device and equipment and computer readable storage medium
CN115766632A (en) Abnormal system early warning compensation method and system, electronic equipment and storage medium
CN115587046A (en) Code exception processing method and device, storage medium and computer equipment
CN113778834B (en) System performance testing method and device of application software and computing equipment
CN111857689A (en) Framework, function configuration method of framework, terminal and storage medium
CN115686899A (en) Terminal abnormity capture analysis method and device
CN111371582A (en) PCIE link fault processing method and device
CN111414270B (en) Exception handling method and device
CN113297149A (en) Method and device for monitoring data processing request
CN113468564A (en) Data processing method and device, electronic equipment and storage medium
CN112083952A (en) Spring architecture-based exception handling method and system
CN111984484A (en) Non-invasive micro-service access method and system
CN117909907B (en) High-throughput computing platform, and anomaly removal method, device and storage medium thereof
CN114756400B (en) Application program exception handling method and system based on android system
CN117290218A (en) Asynchronous interface testing method, device, equipment and 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