Abnormality processing method and device, computer equipment and storage medium

By generating stack seeds in Android application development and using global hash tables to identify exception recursion, the problem of difficulty in accurately identifying and handling exception recursion in the existing technology is solved, and high-accurate exception recursion detection and processing is achieved.

CN119917329APending Publication Date: 2025-05-02SHENZHEN YISHIHUOLALA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411996985.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

The prior art is difficult to accurately identify and handle exception recursion in Android application development, resulting in the impact of application stability and user experience.

Method used

Before the target thread that the target function is preset, the target function is executed, and a global hash table is called to determine whether there is a matching record. If it exists, an exception signal is generated and sent to the target thread to abort its execution.

Benefits of technology

It realizes accurate detection and handling of exception recursion in a non-production environment, improves the accuracy of exception recursion detection of the objective function, and avoids the influence of the exception capture mechanism of the Java virtual machine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917329A_ABST
    Figure CN119917329A_ABST
Patent Text Reader

Abstract

The invention provides an exception handling method and device, computer equipment and a storage medium. The method comprises the steps that before a target function is executed by a preset target thread, a stack seed corresponding to the target function is generated; calling a preset global hash table; judging whether a record matched with the stack seed exists in a global hash table or not; if the record matched with the stack seed exists in the global hash table, generating a corresponding abnormal signal based on a preset signal scheduling strategy; and sending the abnormal signal to the target thread to stop execution of the target virtual machine corresponding to the target thread. According to the method, abnormal recursion identification is carried out on the function based on the use of the global hash table and the stack seed, and the abnormal signal is sent, so that the generation of abnormal recursion can be timely and accurately detected in a non-production environment without being influenced by an abnormal capture mechanism of the Java virtual machine; and the detection accuracy of the abnormal recursion of the target function is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to an exception processing method, device, computer equipment and storage medium. Background Art

[0002] In the current field of Android application development, instrumentation is an important technical means and is widely used in performance monitoring, error capture, code coverage analysis, etc. Instrumentation technology inserts some additional code into the original program code to monitor, test or analyze the program behavior without changing the original logic.

[0003] However, while this kind of instrumentation brings convenience, it also causes a series of potential problems. Especially on the Android side, due to the complexity and diversity of applications, instrumentation often causes the pre-generated classes to be modified after instrumentation, which may lead to abnormal recursion. This abnormal recursion, that is, the program repeatedly calls itself or related functions during execution, causing the program to be unable to exit normally or continue execution, is a common and difficult problem in Android application development.

[0004] When the abnormal recursion is captured by special processing logic, the existing technology does not provide an effective recursive exception identification strategy, which makes it difficult for developers to accurately determine the occurrence and cause of the abnormal recursion, thereby affecting the stability of the application and user experience. Summary of the invention

[0005] The main purpose of the present invention is to provide an exception handling method, apparatus, computer device and storage medium, aiming to solve the technical problem that the prior art does not provide an effective recursive exception identification strategy, making it difficult for developers to accurately determine the occurrence and cause of exception recursion.

[0006] To achieve the above object, the present invention provides an exception handling method, the method comprising:

[0007] Before the target function is executed by a preset target thread, generating a stack seed corresponding to the target function;

[0008] Call the preset global hash table;

[0009] Determine whether there is a record matching the stack seed in the global hash table;

[0010] If there is a record matching the stack seed in the global hash table, generating a corresponding abnormal signal based on a preset signal scheduling strategy;

[0011] The exception signal is sent to the target thread to terminate the execution of the target virtual machine corresponding to the target thread.

[0012] Optionally, generating a stack seed corresponding to the target function includes:

[0013] Obtaining the thread identifier of the target thread;

[0014] Call the preset random number generator;

[0015] generating a random value based on the random number generator;

[0016] The stack seed is generated based on the thread identifier and the random value.

[0017] Optionally, generating the stack seed based on the thread identifier and the random value includes:

[0018] Convert the thread identifier into a string to obtain a corresponding first string;

[0019] Convert the random value into a string to obtain a corresponding second string;

[0020] Get the preset delimiter;

[0021] Performing a string concatenation process on the first string and the second string based on the separator to obtain a corresponding target string;

[0022] The target string is used as the stack seed.

[0023] Optionally, the generating a corresponding abnormal signal based on a preset signal scheduling strategy includes:

[0024] Invoking the signal scheduling strategy;

[0025] Get the preset signal value;

[0026] generating a trap signal corresponding to the signal value based on the signal scheduling strategy;

[0027] The trap signal is used as the abnormal signal.

[0028] Optionally, after sending the exception signal to the target thread to terminate the execution of the target virtual machine corresponding to the target thread, the method further includes:

[0029] Call the preset signal processing function;

[0030] Reading stack information of the target thread based on the signal processing function;

[0031] Printing the stack information to obtain printed target stack information;

[0032] The target stack information is sent to relevant personnel.

[0033] Optionally, after determining whether there is a record matching the stack seed in the global hash table, the method further includes:

[0034] If there is no record matching the stack seed in the global hash table, obtaining a preset write instruction;

[0035] Executing the write instruction to write the stack seed into the global hash table;

[0036] The target function is executed based on the target thread.

[0037] Optionally, after executing the target function based on the target thread, the method further includes:

[0038] Determine whether the target function has been executed;

[0039] If so, query the global hash table for a specified record corresponding to the stack seed;

[0040] The specified record is removed from the global hash table.

[0041] In addition, to achieve the above object, the present invention also provides an exception handling device, the exception handling device comprising:

[0042] A first generating module, used for generating a stack seed corresponding to the target function before the target function is executed by a preset target thread;

[0043] A first calling module is used to call a preset global hash table;

[0044] A first judgment module, used for judging whether there is a record matching the stack seed in the global hash table;

[0045] A second generating module, configured to generate a corresponding abnormal signal based on a preset signal scheduling strategy if there is a record matching the stack seed in the global hash table;

[0046] The first sending module is used to send the abnormal signal to the target thread to terminate the execution of the target virtual machine corresponding to the target thread.

[0047] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0048] The computer device includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of any one of the exception handling methods proposed in the embodiments of the present application are implemented.

[0049] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0050] The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of any one of the exception handling methods proposed in the embodiments of the present application are implemented.

[0051] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0052] The present invention provides an exception handling method, device, computer equipment and storage medium. The method comprises: before a target function is executed by a preset target thread, firstly generating a stack seed corresponding to the target function; then calling a preset global hash table; subsequently judging whether there is a record matching the stack seed in the global hash table; if there is a record matching the stack seed in the global hash table, generating a corresponding exception signal based on a preset signal scheduling strategy; and finally sending the exception signal to the target thread to terminate the execution of a target virtual machine corresponding to the target thread. The present invention generates a stack seed corresponding to the target function and then calls a preset global hash table before the target function is executed by a preset target thread. When it is detected that there is a record matching the stack seed in the global hash table, a corresponding exception signal is generated based on a preset signal scheduling strategy, and then the exception signal is sent to the target thread to terminate the execution of the target virtual machine corresponding to the target thread. Through this exception handling method, the present invention performs exception recursion identification on the function based on the use of the global hash table and the stack seed and sends the exception signal. It can detect the generation of exception recursion in a timely and accurate manner in a non-production environment without being affected by the Java virtual machine exception capture mechanism, and effectively improves the detection accuracy of the exception recursion of the target function. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0054] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0055] Figure 2 is a flow chart of an exception handling method provided by an embodiment of the present invention;

[0056] Figure 3 is a structural schematic diagram of an embodiment of an exception handling device according to the present application;

[0057] Figure 4 This is a basic structural block diagram of the computer device in this embodiment. DETAILED DESCRIPTION

[0058] The exception handling method provided in the embodiment of the present invention is applied to the exception handling device. Unless otherwise defined, all technical and scientific terms used in this article have the same meaning as those generally understood by technicians in the technical field of this application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned drawings and any variations thereof are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0059] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0060] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0061] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0062] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social online platform software, etc.

[0063] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.

[0064] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0065] It should be noted that the exception handling method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the exception handling device is generally arranged in the server / terminal device.

[0066] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0067] In the current field of Android application development, instrumentation is an important technical means and is widely used in performance monitoring, error capture, code coverage analysis, etc. Instrumentation technology inserts some additional code into the original program code to monitor, test or analyze the program behavior without changing the original logic.

[0068] However, while this kind of instrumentation brings convenience, it also causes a series of potential problems. Especially on the Android side, due to the complexity and diversity of applications, instrumentation often causes the pre-generated classes to be modified after instrumentation, which may lead to abnormal recursion. This abnormal recursion, that is, the program repeatedly calls itself or related functions during execution, causing the program to be unable to exit normally or continue execution, is a common and difficult problem in Android application development.

[0069] When the abnormal recursion is captured by special processing logic, the existing technology does not provide an effective recursive exception identification strategy, which makes it difficult for developers to accurately determine the occurrence and cause of the abnormal recursion, thereby affecting the stability of the application and user experience.

[0070] Continue to refer Figure 2, shows a flow chart of an embodiment of the exception handling method proposed in the present application. The embodiment of the present application can acquire and process relevant data based on artificial intelligence technology.

[0071] The exception handling method provided by the embodiment of the present invention comprises the following steps:

[0072] S210, before the target function is executed by a preset target thread, a stack seed corresponding to the target function is generated.

[0073] In this step, the execution subject of the present invention may specifically be an exception handling system, which may be referred to as the system for short. The above-mentioned target function may refer to an active function that is frequently called in an Android application. The above-mentioned target thread refers to the execution unit responsible for executing the above-mentioned target function, which may also be referred to as the current thread. Among them, the above-mentioned stack seed refers to a local variable generated in each stack frame, which is composed of the current thread ID and a random value. The specific implementation process of generating the stack seed corresponding to the target function will be further described in detail in the subsequent specific embodiments of the present invention, and will not be elaborated on here.

[0074] S220, calling a preset global hash table.

[0075] In this step, the global hash table is a pre-built global maintenance data structure for storing stack seeds of currently active function calls. In addition, the global hash table is located at a memory storage location.

[0076] S230, determining whether there is a record matching the stack seed in the global hash table.

[0077] In this step, the stack seed may be used as a key to search in the global hash table whether there is a record matching the stack seed.

[0078] S240, if there is a record matching the stack seed in the global hash table, a corresponding abnormal signal is generated based on a preset signal scheduling strategy. If it is detected that there is no record matching the stack seed in the global hash table, it means that the current target function is called for the first time, or the previous function call has ended normally and the stack seed has been removed from the hash table, and no abnormal recursion has occurred. At this time, the stack seed can be added to the global hash table as a new record for subsequent detection.

[0079] In this step, if a record matching the stack seed is detected in the global hash table, it indicates that the current target function already has one or more unterminated call instances in the execution stack, i.e., an abnormal recursion has occurred. The abnormal signal refers to a signal that complies with the Linux kernel standard. The specific implementation process of generating the corresponding abnormal signal based on the preset signal scheduling strategy will be further described in detail in the subsequent specific embodiments of the present invention, and will not be elaborated on here.

[0080] S250: Send the abnormal signal to the target thread to terminate the execution of the target virtual machine corresponding to the target thread.

[0081] In this step, the above-mentioned exception signal can be sent to the process to which the target thread belongs, which is the target virtual machine process (Java virtual machine process), so that the entire Java virtual machine corresponding to the target thread can be suspended. This can bypass the exception capture mechanism of the Java virtual machine and enable developers to quickly locate problems in a non-production environment.

[0082] In an embodiment of the present invention, before a target function is executed by a preset target thread, a stack seed corresponding to the target function is first generated; then a preset global hash table is called; subsequently, it is determined whether there is a record matching the stack seed in the global hash table; if there is a record matching the stack seed in the global hash table, a corresponding exception signal is generated based on a preset signal scheduling strategy; finally, the exception signal is sent to the target thread to terminate the execution of the target virtual machine corresponding to the target thread. Before a target function is executed by a preset target thread, the present invention generates a stack seed corresponding to the target function and then calls a preset global hash table. When it is detected that there is a record matching the stack seed in the global hash table, a corresponding exception signal is generated based on a preset signal scheduling strategy, and then the exception signal is sent to the target thread to terminate the execution of the target virtual machine corresponding to the target thread. Through this exception handling method, the present invention performs abnormal recursion identification on the function based on the use of the global hash table and the stack seed and sends an exception signal, and can detect the generation of abnormal recursion in a timely and accurate manner in a non-production environment without being affected by the Java virtual machine exception capture mechanism, effectively improving the detection accuracy of abnormal recursion of the target function.

[0083] Optionally, generating a stack seed corresponding to the target function includes:

[0084] Get the thread identifier of the target thread.

[0085] In this step, the target thread refers to the execution unit responsible for executing the target function, which can also be called the current thread. The thread identifier of the target thread refers to the thread ID of the target thread. The system call to obtain the ID of the target thread can be called, which will return a value or structure that is unique in the current process and is used to identify the current thread, that is, the thread ID. This value can be recorded later as part of the stack seed to be generated later.

[0086] Call the preset random number generator.

[0087] In this step, the random number generator has the function of generating random numbers based on a source of sufficient entropy. There is no specific limitation on the selection of the random number generator, which can be selected according to actual business needs, for example, a random number generator based on time, based on environmental noise, based on cryptography, etc. can be used.

[0088] Generates a random value based on the random number generator.

[0089] In this step, when the target function is called and before being executed by the target thread, a new random number corresponding to the target function can be obtained by using the random number generator. In order to ensure the uniqueness of the random number, a larger value range (such as a 64-bit integer) or other information (such as the high-precision part of the timestamp) is further used to increase the probability of uniqueness.

[0090] The stack seed is generated based on the thread identifier and the random value.

[0091] In this step, the specific implementation process of generating the stack seed based on the thread identifier and the random value will be further described in detail in subsequent specific embodiments of the present invention, and will not be elaborated on here.

[0092] In an embodiment of the present invention, the thread identifier of the target thread is obtained; then a preset random number generator is called; then a random value is generated based on the random number generator; and then the stack seed is generated based on the thread identifier and the random value. The present invention obtains the thread identifier of the target thread, then generates a random value based on the use of a random number generator, and then generates the stack seed based on the thread identifier and the random value, so that the stack seed corresponding to the target function can be automatically generated, the generation efficiency of the stack seed is improved, and the generated stack seed is a unique data or data with a high probability of uniqueness, which effectively ensures the data accuracy of the stack seed.

[0093] Optionally, generating the stack seed based on the thread identifier and the random value includes:

[0094] The thread identifier is converted into a string form to obtain a corresponding first string.

[0095] In this step, the thread identifier may be converted into a string form by using the str function, thereby obtaining a corresponding first string.

[0096] The random value is converted into a string form to obtain a corresponding second string.

[0097] In this step, similarly, the random value can be converted into a string form by using the str function to obtain a corresponding second string.

[0098] Get the default delimiter.

[0099] In this step, there is no specific limitation on the selection of the above separators, which can be determined according to actual business needs, for example, a colon, a dash or an underscore can be used.

[0100] The first character string and the second character string are concatenated based on the separator to obtain a corresponding target character string.

[0101] In this step, the first character string and the second character string may be connected by using the separator to generate a connected target character string.

[0102] The target string is used as the stack seed.

[0103] In an embodiment of the present invention, the thread identifier is converted into a string form to obtain a corresponding first string; and the random value is converted into a string form to obtain a corresponding second string; then a preset separator is obtained; then the first string and the second string are string-concatenated based on the separator to obtain a corresponding target string; and the target string is subsequently used as the stack seed. The present invention converts the thread identifier into a string form to obtain a corresponding first string, and converts the random value into a string form to obtain a corresponding second string, and then the first string and the second string are string-concatenated based on the use of a separator, so that the stack seed corresponding to the target function can be efficiently and accurately generated, thereby improving the efficiency of stack seed generation, and the generated stack seed is a unique data or data with a high probability of uniqueness, which effectively ensures the data accuracy of the stack seed.

[0104] Optionally, the generating a corresponding abnormal signal based on a preset signal scheduling strategy includes:

[0105] The signal scheduling policy is invoked.

[0106] In this step, the signal scheduling strategy may specifically be a Linux signal scheduling mechanism.

[0107] Get the preset signal value.

[0108] In this step, the signal value is specifically 5.

[0109] A trap signal corresponding to the signal value is generated based on the signal scheduling policy.

[0110] In this step, a trap signal with a signal value of 5 can be generated through the Linux signal scheduling mechanism to interrupt the execution of the current thread, that is, the target thread.

[0111] The trap signal is used as the abnormal signal.

[0112] In an embodiment of the present invention, the signal scheduling strategy is called; a preset signal value is obtained; a trap signal corresponding to the signal value is generated based on the signal scheduling strategy; and the trap signal is subsequently used as the exception signal. The present invention effectively improves the intelligence of the generation of exception signals by calling the signal scheduling strategy, obtaining the preset signal value, and then generating a trap signal corresponding to the signal value based on the use of the signal scheduling strategy as the required exception signal. The exception signal can be used to forcibly interrupt the execution process of the target thread when an exception recursion is detected in the target function, thereby bypassing the exception capture mechanism of the Java virtual machine, allowing developers to quickly locate problems in non-production environments.

[0113] Optionally, after sending the exception signal to the target thread to terminate the execution of the target virtual machine corresponding to the target thread, the method further includes:

[0114] Call the preset signal processing function.

[0115] In this step, the above abnormal signal is a special signal used to interrupt the execution of the thread and trigger the corresponding signal processing function. The main task of the signal processing function is to print out the stack information of the current thread, including the function call chain, parameter values, etc.

[0116] The stack information of the target thread is read based on the signal processing function.

[0117] In this step, the stack information of the target thread can be obtained by reading the memory map and call stack of the target thread using the signal processing function, and the stack information includes the function call chain, parameter values, etc. of the target function.

[0118] The stack information is printed to obtain printed target stack information.

[0119] In this step, after the stack information of the target thread is read, the stack information can be further printed out to obtain the corresponding target stack information.

[0120] The target stack information is sent to relevant personnel.

[0121] In this step, the above-mentioned relevant personnel may be developers. Among them, by sending the target stack information to the developer, the developer can quickly locate the function or method where the abnormal recursion occurs according to the printed target stack information. Then, by analyzing the function call chain and parameter values, the developer can understand the cause of the abnormal recursion. Then, based on the analysis results, the developer can make corresponding repairs to the code to eliminate the abnormal recursion, thereby avoiding the jamming of the application and ensuring the stable operation of the application.

[0122] In an embodiment of the present invention, a preset signal processing function is called; then the stack information of the target thread is read based on the signal processing function; then the stack information is printed to obtain the printed target stack information; and then the target stack information is sent to relevant personnel. The present invention calls a preset signal processing function, reads the stack information of the target thread based on the use of the signal processing function, and prints the stack information to obtain the printed target stack information, and then automatically and intelligently sends the target stack information to relevant personnel, so that the relevant personnel can quickly locate the target function where the abnormal recursion occurs and understand the cause of the abnormal recursion of the target function by consulting the target stack information, and then can perform corresponding repairs on the code according to the analysis results to eliminate the abnormal recursion, thereby helping to ensure the normal execution of the target function.

[0123] Optionally, after determining whether there is a record matching the stack seed in the global hash table, the method further includes:

[0124] If there is no record matching the stack seed in the global hash table, a preset write instruction is obtained.

[0125] In this step, if it is detected that there is no record matching the stack seed in the global hash table, it means that the current target function is called for the first time in the current target thread and no abnormal recursion occurs. Then the stack seed needs to be written into the global hash table later so as to perform abnormal recursion detection corresponding to the target function later. The write instruction is an instruction with the function of writing the stack seed into the global hash table.

[0126] The write instruction is executed to write the stack seed into the global hash table.

[0127] In this step, the stack seed may be written into the global hash table as a new record by executing the write instruction.

[0128] The target function is executed based on the target thread.

[0129] In this step, because the current call of the target function is legal, the target function should continue to execute its logic, and then execute the target function through the above target thread.

[0130] In an embodiment of the present invention, if there is no record matching the stack seed in the global hash table, a preset write instruction is obtained; then the write instruction is executed to write the stack seed into the global hash table; and the target function is subsequently executed based on the target thread. When the present invention detects that there is no record matching the stack seed in the global hash table, it will intelligently obtain a preset write instruction and execute the write instruction to write the stack seed into the global hash table, so that the subsequent use of the global hash table and the stack seed can efficiently and accurately determine whether an abnormal recursion has occurred in the target function, thereby effectively ensuring the accuracy of detecting abnormal recursion of the target function. In addition, the target function will be executed based on the target thread to ensure the execution standardization and execution accuracy of the target function.

[0131] Optionally, after executing the target function based on the target thread, the method further includes:

[0132] Determine whether the target function has been executed.

[0133] In this step, after a preset period of time has passed, it can be detected whether the above-mentioned objective function has been executed. The above-mentioned preset time can be determined according to an actual experience value. By detecting whether the objective function has been executed after a period of time, it is possible to avoid real-time detection of whether the objective function has been executed, thereby reducing the detection workload and improving the detection intelligence.

[0134] If so, a designated record corresponding to the stack seed is queried from the global hash table.

[0135] In this step, after the target function is executed, the system will access the global hash table and use the above stack seed as the key to find the corresponding specified record.

[0136] The specified record is removed from the global hash table.

[0137] In this step, a removal operation can be performed in the global hash table to remove the specified record corresponding to the stack seed that already exists in the global hash table. This ensures that when the target function ends normally, its stack seed will not interfere with the exception recursion detection of subsequent function calls, thereby ensuring that the exception recursion detection of other subsequent function calls can be performed correctly.

[0138] In an embodiment of the present invention, it is determined whether the target function has been executed; if so, the designated record corresponding to the stack seed is queried from the global hash table; and the designated record is subsequently removed from the global hash table. After detecting that the target function has been executed, the present invention automatically and intelligently queries the designated record corresponding to the stack seed from the global hash table, and then removes the designated record from the global hash table, thereby ensuring that subsequent abnormal recursive detection of other function calls can be performed correctly, effectively improving the detection intelligence and detection accuracy of abnormal recursive detection of functions.

[0139] In some optional implementations, the user information obtained is subject to the user's consent and complies with relevant laws and policies.

[0140] Further references Figure 3 , as a response to the above Figure 2 In order to realize the method shown in the figure, the present application provides an embodiment of an exception handling device 300, which is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0141] An embodiment of the present invention provides an exception handling device 300, and the exception handling device 300 includes:

[0142] A first generating module 310, used for generating a stack seed corresponding to the target function before the target function is executed by a preset target thread;

[0143] A first calling module 320 is used to call a preset global hash table;

[0144] A first determination module 330, configured to determine whether there is a record matching the stack seed in the global hash table;

[0145] A second generating module 340 is configured to generate a corresponding abnormal signal based on a preset signal scheduling strategy if there is a record matching the stack seed in the global hash table;

[0146] The first sending module 350 is used to send the abnormal signal to the target thread to terminate the execution of the target virtual machine corresponding to the target thread.

[0147] Optionally, the first generating module 310 includes:

[0148] A first acquisition submodule, used to acquire the thread identifier of the target thread;

[0149] The first calling submodule is used to call a preset random number generator;

[0150] A first generating submodule, used for generating a random value based on the random number generator;

[0151] The second generating submodule is used to generate the stack seed based on the thread identifier and the random value.

[0152] Optionally, the second generating submodule includes:

[0153] A first conversion unit, configured to convert the thread identifier into a string form to obtain a corresponding first string;

[0154] A second conversion unit, used to convert the random value into a string form to obtain a corresponding second string;

[0155] An acquisition unit is used to obtain a preset delimiter;

[0156] a concatenation unit, configured to perform a string concatenation process on the first string and the second string based on the separator to obtain a corresponding target string;

[0157] A determination unit is used to use the target string as the stack seed.

[0158] Optionally, the second generating module 340 includes:

[0159] A second calling submodule, used for calling the signal scheduling strategy;

[0160] The second acquisition submodule is used to obtain a preset signal value;

[0161] A third generating submodule, configured to generate a trap signal corresponding to the signal value based on the signal scheduling strategy;

[0162] A determination submodule is used to use the trap signal as the abnormal signal.

[0163] Optionally, the exception handling device 300 further includes:

[0164] The second calling module is used to call a preset signal processing function;

[0165] A reading module, used for reading the stack information of the target thread based on the signal processing function;

[0166] A printing module, used for printing the stack information to obtain printed target stack information;

[0167] The second sending module is used to send the target stack information to relevant personnel.

[0168] Optionally, the exception handling device 300 further includes:

[0169] an acquisition module, configured to acquire a preset write instruction if no record matching the stack seed exists in the global hash table;

[0170] A first execution module, configured to execute the write instruction to write the stack seed into the global hash table;

[0171] The second execution module is used to execute the target function based on the target thread.

[0172] Optionally, the exception handling device 300 further includes:

[0173] A second judgment module is used to judge whether the target function has been executed;

[0174] A query module, configured to query a specified record corresponding to the stack seed from the global hash table if yes;

[0175] A removal module is used to remove the specified record from the global hash table.

[0176] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0177] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0178] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0179] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as the program code of the exception handling method, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0180] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the program code stored in the memory 41 or process data, such as running the program code of the exception handling method.

[0181] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0182] Compared with the prior art, the embodiments of the present invention mainly have the following beneficial effects:

[0183] In an embodiment of the present application, before the target function is executed by the preset target thread, a stack seed corresponding to the target function is first generated; then a preset global hash table is called; subsequently, it is determined whether there is a record matching the stack seed in the global hash table; if there is a record matching the stack seed in the global hash table, a corresponding exception signal is generated based on a preset signal scheduling strategy; finally, the exception signal is sent to the target thread to terminate the execution of the target virtual machine corresponding to the target thread. The present invention generates a stack seed corresponding to the target function and then calls a preset global hash table before the target function is executed by the preset target thread. When it is detected that there is a record matching the stack seed in the global hash table, a corresponding exception signal is generated based on a preset signal scheduling strategy, and then the exception signal is sent to the target thread to terminate the execution of the target virtual machine corresponding to the target thread. Through this exception handling method, the present invention performs abnormal recursion identification on the function based on the use of the global hash table and the stack seed and sends an exception signal. It can detect the generation of abnormal recursion in a timely and accurate manner in a non-production environment without being affected by the Java virtual machine exception capture mechanism, and effectively improves the detection accuracy of abnormal recursion of the target function.

[0184] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores the application crash handler, and the application crash handler can be executed by at least one processor so that the at least one processor performs the steps of the above-mentioned exception handling method.

[0185] Compared with the prior art, the embodiments of the present invention mainly have the following beneficial effects:

[0186] In an embodiment of the present application, before the target function is executed by the preset target thread, a stack seed corresponding to the target function is first generated; then a preset global hash table is called; subsequently, it is determined whether there is a record matching the stack seed in the global hash table; if there is a record matching the stack seed in the global hash table, a corresponding exception signal is generated based on a preset signal scheduling strategy; finally, the exception signal is sent to the target thread to terminate the execution of the target virtual machine corresponding to the target thread. The present invention generates a stack seed corresponding to the target function and then calls a preset global hash table before the target function is executed by the preset target thread. When it is detected that there is a record matching the stack seed in the global hash table, a corresponding exception signal is generated based on a preset signal scheduling strategy, and then the exception signal is sent to the target thread to terminate the execution of the target virtual machine corresponding to the target thread. Through this exception handling method, the present invention performs abnormal recursion identification on the function based on the use of the global hash table and the stack seed and sends an exception signal. It can detect the generation of abnormal recursion in a timely and accurate manner in a non-production environment without being affected by the Java virtual machine exception capture mechanism, and effectively improves the detection accuracy of abnormal recursion of the target function.

[0187] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware online platform, and of course, by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0188] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0189] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. An exception handling method, characterized in that: include: Before the target function is executed by a preset target thread, generating a stack seed corresponding to the target function; Call the preset global hash table; Determine whether there is a record matching the stack seed in the global hash table; If there is a record matching the stack seed in the global hash table, generating a corresponding abnormal signal based on a preset signal scheduling strategy; The exception signal is sent to the target thread to terminate the execution of the target virtual machine corresponding to the target thread.

2. The method according to claim 1, characterized in that The generating a stack seed corresponding to the target function comprises: Obtaining the thread identifier of the target thread; Call the preset random number generator; generating a random value based on the random number generator; The stack seed is generated based on the thread identifier and the random value.

3. The method according to claim 2, characterized in that The generating the stack seed based on the thread identifier and the random value comprises: Convert the thread identifier into a string to obtain a corresponding first string; Convert the random value into a string to obtain a corresponding second string; Get the preset delimiter; Performing a string concatenation process on the first string and the second string based on the separator to obtain a corresponding target string; The target string is used as the stack seed.

4. The method according to claim 1, characterized in that: The generating of a corresponding abnormal signal based on a preset signal scheduling strategy includes: Invoking the signal scheduling strategy; Get the preset signal value; generating a trap signal corresponding to the signal value based on the signal scheduling strategy; The trap signal is used as the abnormal signal.

5. The method according to claim 1, characterized in that After sending the abnormal signal to the target thread to terminate the execution of the target virtual machine corresponding to the target thread, the method further includes: Call the preset signal processing function; Reading stack information of the target thread based on the signal processing function; Printing the stack information to obtain printed target stack information; The target stack information is sent to relevant personnel.

6. The method according to claim 1, characterized in that After determining whether there is a record matching the stack seed in the global hash table, the method further includes: If there is no record matching the stack seed in the global hash table, obtaining a preset write instruction; Executing the write instruction to write the stack seed into the global hash table; The target function is executed based on the target thread.

7. The method according to claim 6, characterized in that After executing the target function based on the target thread, the method further includes: Determine whether the target function has been executed; If so, query the global hash table for a specified record corresponding to the stack seed; The specified record is removed from the global hash table.

8. An exception handling device, characterized in that: include: A first generating module, used for generating a stack seed corresponding to the target function before the target function is executed by a preset target thread; A first calling module is used to call a preset global hash table; A first judgment module, used for judging whether there is a record matching the stack seed in the global hash table; A second generating module, configured to generate a corresponding abnormal signal based on a preset signal scheduling strategy if there is a record matching the stack seed in the global hash table; The first sending module is used to send the abnormal signal to the target thread to terminate the execution of the target virtual machine corresponding to the target thread.

9. A computer device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the exception handling method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the exception handling method according to any one of claims 1 to 7 are implemented.