Application exception processing method, device, equipment and storage medium
By monitoring the running status of the application and taking hierarchical recovery measures, the problem of complex and time-consuming application exception handling in the existing technology is solved, and the stable operation of the application and the improvement of user experience are achieved.
Patent Information
- Application Number
- CN202011101982.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-15
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2040-10-15
AI Technical Summary
When handling application exceptions, existing technologies require the creation of patch packages, which is a complex and time-consuming process and may cause users to frequently crash, affecting user experience and increasing the risk of user churn.
By monitoring the application's running status, the system architecture layer corresponding to the anomaly is determined and hierarchical recovery measures are taken. For application layer anomalies, the corresponding handling strategy is adopted according to the anomaly category; for local framework layer anomalies, the current value of the register is modified to restore the application to normal operation.
It reduces application crashes, improves operational stability, reduces users' perception of anomalies, and reduces user churn.
Smart Images

Figure CN114371949B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of mobile communication technology, and in particular to a method, apparatus, device, and storage medium for processing application exceptions. Background Art
[0002] Existing technology for handling online application anomalies requires creating a patch. This method requires the application (APP) to proactively monitor the user for anomalies and collect and report such information. However, users may refuse to allow the APP to collect and report such information. Furthermore, the patch creation and distribution process is typically lengthy and involves numerous personnel. It takes time from the moment a crash occurs on the user side to the moment a large number of crashes are detected and an alert is triggered. Delivering a patch requires finding the source code for the corresponding online version. After locating the fix, the APK must be rebuilt and then diffed with the live APK. After the patch is created, testers must perform regression testing in a test environment across various device models and ROM versions before it can be released to the live network. Furthermore, release to the live network requires a phased rollout to observe the effectiveness of the fix. The entire process typically takes 2-3 hours. Furthermore, due to the time required to distribute the patch, users may experience continuous crashes, impacting their app's functionality and even leading to user churn.
[0003] Therefore, it is necessary to provide a method, apparatus, device and storage medium for handling application exceptions, and take hierarchical recovery measures for application exceptions, thereby reducing application crashes and improving the operating stability of the application. Summary of the Invention
[0004] The present application provides a method, apparatus, device, and storage medium for handling application exceptions, which can reduce application crashes and improve the operating stability of applications, thereby reducing users' perception of exceptions and reducing user churn of applications.
[0005] In one aspect, the present application provides a method for handling application exceptions, the method comprising:
[0006] Monitor the running status of the application;
[0007] When the application program runs abnormally, determining the system architecture layer corresponding to the abnormality;
[0008] When the anomaly is located at the application layer, determining the category to which the anomaly belongs;
[0009] Determining a handling strategy for the exception based on the category to which the exception belongs;
[0010] When the exception is located in the local framework layer, monitoring the signal in the exception through the signal processing function;
[0011] When the exception includes a target signal, obtaining a current value of a target register;
[0012] The current value of the target register is adjusted to a safe value so that the application program can run normally.
[0013] Another aspect provides a device for processing application exceptions, the device comprising:
[0014] Status monitoring module, used to monitor the running status of the application;
[0015] A system architecture layer determination module, configured to determine the system architecture layer corresponding to the abnormality when the application program runs abnormally;
[0016] A category determination module, configured to determine the category to which the exception belongs when the exception is located at the application layer;
[0017] A processing strategy determination module, configured to determine a processing strategy for the exception according to the category to which the exception belongs;
[0018] A signal monitoring module, configured to monitor the signal in the exception through a signal processing function when the exception is located in the local framework layer;
[0019] a current value acquisition module, configured to acquire a current value of a target register when the exception includes a target signal;
[0020] The current value adjustment module is used to adjust the current value of the target register to a safe value so that the application program can run normally.
[0021] On the other hand, a device for processing application exceptions is provided, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the method for processing application exceptions as described above.
[0022] On the other hand, a computer-readable storage medium is provided, which stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by a processor to implement the above-mentioned method for handling application exceptions.
[0023] The application exception handling method, apparatus, device, and storage medium provided in this application have the following technical effects:
[0024] In this application, when an application runs abnormally, the system architecture layer corresponding to the abnormality is determined, and different processing strategies are adopted for abnormalities at different layers. For application layer abnormalities, corresponding processing strategies are adopted according to the abnormality category. For local framework layer abnormalities, the current value of the register is modified to restore the application to normal. The technical solution of this application adopts hierarchical recovery measures for application abnormalities, reduces application crashes, improves application operation stability, thereby reducing users' perception of abnormalities and reducing user churn. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions and advantages of the embodiments of the present application or the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0026] Figure 1 is a schematic diagram of a system for handling application exceptions provided in an embodiment of the present application;
[0027] Figure 2 This is a flowchart of a method for handling application exceptions provided by an embodiment of the present application;
[0028] Figure 3 This is a flowchart of a method for monitoring exceptions through Thread.uncaught Exception Handler (Uncaught Handler for short) provided in an embodiment of the present application;
[0029] Figure 4 This is a flowchart of a method for determining an exception handling strategy based on the category to which the exception belongs, provided by an embodiment of the present application;
[0030] Figure 5 This is a flowchart of an exception handling method provided by an embodiment of the present application when the exception is located at the application layer and the category to which the exception belongs cannot be determined;
[0031] Figure 6 1 is a flowchart of an exception handling method when the target thread does not include a message processing class provided by an embodiment of the present application;
[0032] Figure 7 1 is a flow chart of a method for obtaining the current value of a target register provided by an embodiment of the present application;
[0033] Figure 8 This is a schematic diagram of the structure of a blockchain system provided by an embodiment of the present application;
[0034] Figure 9 This is a schematic diagram of the block structure provided by an embodiment of the present application;
[0035] Figure 10 This is a schematic diagram of the structure of a device for processing application exceptions provided in an embodiment of the present application;
[0036] Figure 11 This is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0038] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0039] See also Figure 1 , Figure 1 Schematic diagram of a system for processing application exceptions provided by an embodiment of the present application. Figure 1 As shown, the application exception processing system may include at least a server 01 and a client 02 .
[0040] Specifically, in the embodiments of this specification, the server 01 may include an independently operated server, or a distributed server, or a server cluster composed of multiple servers. It may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Server 01 may include a network communication unit, a processor, a memory, and the like. Specifically, the server 01 can be used to store exception information and exception handling strategies of applications.
[0041] Specifically, in the embodiments of this specification, the client 02 may include a physical device such as a smartphone, desktop computer, tablet computer, laptop computer, digital assistant, smart wearable device, or vehicle-mounted terminal. It may also include software running on the physical device, such as a webpage provided to a user by a service provider, or an application provided to a user by such a service provider. Specifically, the client 02 may be used to determine the exception category of an application and handle the application exception.
[0042] The following describes a method for handling application exceptions in this application. Figure 2 It is a flowchart of a method for handling application exceptions provided by an embodiment of the present application. This specification provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many, and does not represent the only execution order. When the actual system or server product is executed, it can be executed sequentially or in parallel according to the method shown in the embodiment or the accompanying drawings (for example, in a parallel processor or multi-threaded processing environment). Specifically, Figure 2 As shown, the method may include:
[0043] S201: Monitor the running status of the application.
[0044] In the embodiments of this specification, the application may be an application in the terminal, for example, the application may be a game application, a news application, a multimedia information application, etc.; the running status of the application is monitored by the terminal, and the running status may include a normal running status and an abnormal running status.
[0045] S203: When the application program runs abnormally, the system architecture layer corresponding to the abnormality is determined.
[0046] In the embodiments of this specification, the system architecture layer corresponding to the exception may include an application layer and a local framework layer. In the Android system, the application layer may be the JVM (Java Virtual Machine) layer, which refers to the Android application layer written in Java / Kotlin, generally a dex file. The dex file is the executable file of the Android system, containing all the operating instructions and runtime data of the application; the local framework layer may be the Native layer; the Native layer refers to the Android dynamic link library written in C / C++, generally a so file; the so file is a program function library under Linux, that is, compiled code and data that can be used by other programs. During the operation of the application, a series of abnormal situations may be caused by factors such as insufficient memory and link errors. If the exception is not handled, the application will not be able to continue to operate normally, and even the application will frequently crash. Crash refers to the sudden exit interruption when opening or using an application, which is manifested as the application screen flashing by and then returning to the desktop. At this time, the corresponding exception handling strategy can be determined according to the system architecture layer corresponding to the abnormal situation. The technical solution of this application is not only applicable to the Android system, but can also be extended to the iOS system and Windows system.
[0047] In the embodiments of this specification, before an application is officially launched, testers will test and analyze it. Through testing, some anomalies can be discovered, such as edge path anomalies, background configuration anomalies, interface data anomalies, and individual read-only memory (ROM) compatibility anomalies. For these anomalies, corresponding handling strategies can be set to avoid pop-up notifications to users and prevent them from affecting their normal use of the application. However, there may still be anomalies that testers do not discover, that is, uncaught anomalies. The anomalies in the embodiments of this specification refer to uncaught anomalies.
[0048] S205: When the exception is located at the application layer, determine the category to which the exception belongs.
[0049] In the embodiments of this specification, in an Android system, the application layer may be the JVM (Java Virtual Machine) layer; exceptions may include out-of-memory exceptions, link error exceptions, or other serious blacklisted exceptions. In an Android system, you can register a Thread.uncaught Exception Handler to listen for exceptions and handle the exception information appropriately, thereby bypassing the system's killing of the abnormal process and preventing application crashes.
[0050] In a specific embodiment, Figure 3As shown, Figure 3 This is a flowchart of a method for monitoring exceptions using the Thread.uncaughtExceptionHandler (Uncaught Handler for short). First, a process is created within the application. Then, the UncaughtHandler API is called. The UncaughtHandler runs to monitor the process and determine whether an exception has occurred. If so, the UncaughtHandler checks for a catch block corresponding to the anomalous process, confirming that the exception was not caught and destroying the anomalous thread. After destroying the anomalous thread, the process returns to the UncaughtHandler call. If no catch block exists for the anomalous process, the process returns to the UncaughtHandler call. Calling the UncaughtHandler API kills the anomalous process within the application and sends a pop-up message to the server, providing the tester with detailed crash information. The tester can be the application developer. The pop-up message can be sent as a toast, a non-modal pop-up window that displays a small message as a reminder or feedback, typically used to indicate the result of an operation or a change in application status. For example, when a user sends a text message, the app displays a toast notification notifying the user that the message has been sent.
[0051] S207: Determine an exception handling strategy based on the category to which the exception belongs.
[0052] In the embodiments of this specification, different functions may be called to determine a processing strategy to handle the exception according to the category to which the exception belongs, thereby avoiding application crashes.
[0053] Specifically, in the embodiments of this specification, Figure 4 As shown, according to the category to which the exception belongs, the strategy for handling the exception may include:
[0054] S2071: When the exception is insufficient memory, clean up the memory cache and ignore the exception.
[0055] In the embodiments of this specification, "out of memory" (OMO) refers to insufficient internal storage space in an application. In this case, memory cleanup is required to free up memory space. When performing memory cache cleanup, the image library memory cache can be cleaned. Ignoring exceptions means that the application will not crash and will continue to display the current page. After the memory cache cleanup is complete, the application will continue to operate normally. In the Android system, you can ignore exceptions by calling the Finalize time outException application programming interface (API).
[0056] S2073: When the exception is a link error, close the exception plug-in.
[0057] In the embodiment of this specification, the link error may be a Linkage Error. For the WeChat application, the Linkage Error may be a WeChat Moments link error. In this case, you can disable the corresponding Moments plug-in to avoid the WeChat application from crashing.
[0058] Specifically, in the embodiment of this specification, when the exception is a link error, closing the exception plug-in may include:
[0059] S20731: When the exception is a link error, determine the exception stack information corresponding to the exception;
[0060] In the embodiment of this specification, the exception stack information corresponding to the exception can be determined through the Linkage Error application program interface.
[0061] S20733: Determine the abnormal plug-in based on the exception stack information;
[0062] In the embodiment of this specification, the exception plug-in corresponding to the exception can be determined through the relevant attribute information of the exception stack.
[0063] S20735: Close abnormal plug-in.
[0064] In the embodiments of this specification, the exception in the application can be eliminated by closing the exception plug-in to avoid the application from crashing. This operation also refers to ignoring the exception in the application.
[0065] S2075: When the exception is a blacklist exception, restart the application and jump to the target page, which is the page before the application is restarted.
[0066] In the embodiments of this specification, the exceptions in the blacklist may be exceptions customized by the tester; such exceptions generally refer to serious exceptions that the system cannot handle, for example, the exceptions in the blacklist may include exceptions that the class cannot be found, exceptions that the SD card is unavailable, or other exceptions that the system cannot handle. The target page is the page before the application is restarted, that is, the page where the user last stayed before the application was restarted. For this exception, the application needs to be restarted, and the page after the restart is the page where the user last stayed before the restart, so that the corresponding user of the application can continue to browse the page where he stayed before, without having to start browsing from the homepage of the application, thereby improving the user's browsing efficiency. In the embodiments of this specification, the user refers to the user who is using the application.
[0067] In the embodiments of this specification, Figure 5 As shown, when the exception is located at the application layer and the category to which the exception belongs cannot be determined, the method may further include:
[0068] S2061: Calling the system application program interface to determine the target thread corresponding to the exception;
[0069] In the embodiments of this specification, the system application interface can be Thread.uncaught ExceptionHandler. Through this API, the target thread corresponding to the current exception of the application can be obtained. The target thread is the thread corresponding to the exception. The thread is the basic unit of task scheduling and execution. Handler is mainly used for processing asynchronous messages: when a message is sent, it first enters a message queue, the function that sends the message returns immediately, and another part takes out the messages one by one from the message queue and then processes the messages. In other words, sending and receiving messages are not synchronous processing. This mechanism is usually used to handle relatively time-consuming operations.
[0070] S2063: Determine whether the target thread includes a message processing class;
[0071] In the embodiments of this specification, the message processing class can be a Looper class; Handler has an important member variable Looper, which maintains a message queue (Message Queue). When we use handler.post or sendMessage related methods, the message is placed in the message queue. Each thread will have its own Looper.
[0072] The Looper class in Android is a class that encapsulates the message loop and message queue, and is used to process messages in Android threads. The handler can actually be seen as a tool class used to insert messages into the message queue.
[0073] (1) The Looper class is used to start a message loop for a thread.
[0074] By default, new threads in Android do not have a message loop enabled. (Except for the main thread, for which the system automatically creates a Looper object and enables a message loop.)
[0075] The Looper object stores messages and events through the Message Queue. A thread can only have one Looper, corresponding to one Message Queue.
[0076] (2) Usually, the interaction with Looper is done through Handler object. Handler can be regarded as an interface of Looper, which is used to send messages to the specified Looper and define the processing method.
[0077] By default, the Handler is bound to the Looper of the thread in which it is defined. For example, if the Handler is defined in the main thread, it is bound to the Looper of the main thread.
[0078] S2065: If the target thread includes a message processing class, determine whether the target thread is the main thread;
[0079] Specifically, in the embodiments of this specification, when the target thread includes the message processing class Looper class, it is further determined whether the target thread is the main thread. The main thread is when a program is started, a process is created by the operating system (OS), and at the same time a thread is immediately run. Because it is executed when the program starts, if another thread needs to be created, the created thread is a child thread of the main thread. Every process has at least one main thread. In Winform, it should be the thread that creates the GUI. The importance of the main thread is reflected in two aspects: 1. It is the thread that generates other child threads; 2. It usually must be the last to complete the execution, such as performing various shutdown actions. Each thread has a unique identifier to distinguish the primary and secondary relationships in the thread.
[0080] The thread's unique identifier is Thread.CurrentThread.ManagedThreadID. For example, the UI and Main function are both main threads. Method bodies or delegates contained within a Thread are all child threads. Delegates can contain multiple method bodies, executed using this.Invoke. You can also define multiple method bodies and execute them within a Thread. These method bodies are all child threads.
[0081] In the embodiment of this specification, whether the target thread is the main thread can be determined by a first function; the first function can be Looper.loop().
[0082] S2067: If the target thread is the main thread, close the current page corresponding to the target thread;
[0083] In the embodiment of the present specification, when the target thread is the main thread, it is necessary to close the current page corresponding to the target thread to avoid the application program from crashing.
[0084] S2069: If the target thread is not the main thread, continue running the target thread.
[0085] In the embodiment of this specification, when the target thread is a non-main thread, the target thread may be a child thread. When the target thread is a child thread, the exception may be ignored and the target thread may continue to run.
[0086] Specifically, in the embodiments of this specification, Figure 6 As shown, if the target thread does not include a message processing class, the method may further include:
[0087] S20661: Determine whether the target thread is an abnormal thread;
[0088] In the embodiment of this specification, whether the target thread is an abnormal thread can be determined by a second function; the second function can be Thread.run().
[0089] S20663: If the target thread is an abnormal thread, close the abnormal thread;
[0090] In the embodiment of this specification, by finding and closing abnormal threads, application crashes can be avoided.
[0091] S20665: If the target thread is a non-exceptional thread, continue running the target thread.
[0092] S209: When the exception is located in the local framework layer, the signal in the exception is monitored through the signal processing function.
[0093] In the embodiment of the present specification, in an Android system, the local framework layer may be a Native layer, wherein the signal processing function may be a signal function, and abnormal signals may be monitored by registering the signal function.
[0094] S2011: When the exception includes a target signal, obtain the current value of the target register.
[0095] In the embodiments of this specification, the target signal may include signals such as SIGSEGV and SIGABRT. When the target signal is monitored, the current value of the target register is obtained.
[0096] In the embodiments of this specification, Figure 7 As shown, when the exception includes a target signal, obtaining the current value of the target register includes:
[0097] S20111: When the exception includes the target signal, obtain context information of the exception;
[0098] In the embodiment of this specification, the context information of the exception may include the value and status information of each register.
[0099] S20113: Obtain the current value of the target register according to the exception context information.
[0100] In the embodiments of this specification, the current value of the target register can be determined through context. The target register may include a PC register and an SP register; the PC register is responsible for storing the memory address, which points to the next instruction to be executed. Each time an instruction is interpreted and executed, the value of the PC register is automatically updated to the address of the next instruction; PC is a 16-bit program counter (PC), which does not belong to the category of special function registers. Programmers do not access PC like accessing special function registers. The SP (Stack Pointer) register refers to the stack pointer register, which indicates the top address of the stack.
[0101] S2013: Adjust the current value of the target register to a safe value so that the application can run normally.
[0102] In the embodiments of this specification, when an exception occurs, the current value of the target register is the exception value. The value of the target register can be modified to a safe value. The exception method can be bypassed and another method can be used to continue executing the current process of the application, thereby ensuring the normal operation of the application.
[0103] Specifically, in the embodiment of this specification, before the step of adjusting the current value of the target register to a safe value to enable the normal operation of the application program, the method may further include:
[0104] Use the exception context information to trace back the exception call stack.
[0105] Specifically, in the embodiments of this specification, the exception context information, that is, the stack frame of the signal processing function will record the address of the current stack, the value of the register, and the address of the function's return value (ret). Through this information, the call stack can be traced back. This is the principle of back trace.
[0106] In the embodiments of this specification, the call stack (abbreviated as "the stack"), also known as the execution stack, control stack, runtime stack, and machine stack, is a stack in computer science that stores messages related to running subroutines. Sometimes simply referred to as "stack," the stack does not necessarily store only subroutine messages. Almost all computer programs rely on a call stack, but high-level languages typically hide the details of the call stack behind the scenes.
[0107] The call stack is most often used to store the return address of subroutines. When calling any subroutine, the main program must temporarily store the address to which the subroutine should return after execution. Therefore, if the called subroutine calls another subroutine, its own return address must be stored on the call stack and retrieved after its own execution completes. In a recursive program, each level of recursion requires an address to be added to the call stack. Therefore, if the program has infinite recursion (or simply too many levels of recursion), the call stack will overflow.
[0108] The main function of the call stack is to store return addresses. In addition, the call stack is also used to store:
[0109] Local variables: Subroutine variables can be stored in the call stack, so that variables between different subroutines can be separated.
[0110] Parameter passing: If the registers are not large enough to hold the subroutine's parameters, the parameters can be stored on the call stack.
[0111] Environment transfer: Some languages (such as Pascal and Ada) support "multi-level subroutines", that is, subroutines can use the local variables of the main program. These variables can be passed to the subroutine through the call stack.
[0112] In the embodiment of this specification, adjusting the current value of the target register to a safe value so that the application program can run normally includes:
[0113] The target register value is adjusted to a safe value through the call stack so that the application can run normally.
[0114] In the embodiments of this specification, the value of the target register can be modified through the call stack. For example, the values of the PC register and the SP register can be modified to within the safe range of each register through the call stack, thereby avoiding application crashes.
[0115] In the embodiments of this specification, when an exception occurs, for non-serious exceptions, automatic retry, ignoring, etc. are adopted to reduce user perception; for serious exceptions, the page where the user last stayed is automatically restarted to avoid pop-ups disturbing the user; due to the adoption of graded recovery measures, the user's perception of the exception is greatly reduced, the usage experience of the main path is guaranteed, more time is gained for sending patch packages, the stability of the application is improved, and user complaints are reduced.
[0116] In the embodiment of this specification, when the application runs abnormally and resumes normal operation, the method further includes:
[0117] Send a prompt message to the server, which includes application exception information and exception handling strategy.
[0118] In the embodiment of the present specification, after the exception handling of the application is completed, a prompt message may be sent to the background server corresponding to the application, so that the server stores the exception information and exception handling strategy of the application.
[0119] Specifically, in the embodiments of this specification, the method may further include:
[0120] The server stores application exception information and exception handling strategies based on the blockchain system. The blockchain system includes multiple nodes, and a peer-to-peer network is formed between the multiple nodes.
[0121] In some embodiments, the blockchain system can be Figure 8 The structure shown in the figure shows a peer-to-peer (P2P) network consisting of multiple nodes. The P2P protocol is an application layer protocol that runs on top of the Transmission Control Protocol (TCP). In a blockchain system, any machine, such as a server or terminal, can join and become a node. A node consists of the hardware layer, the middle layer, the operating system layer, and the application layer.
[0122] Figure 8 The functions of each node in the blockchain system shown include:
[0123] 1) Routing: A basic function of a node, used to support communication between nodes.
[0124] In addition to the routing function, nodes can also have the following functions:
[0125] 2) Applications, deployed in the blockchain, implement specific services based on actual business needs, record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system for other nodes to add the record data to a temporary block when they successfully verify the source and integrity of the record data.
[0126] 3) Blockchain, including a series of blocks that are connected to each other in the order of their generation. Once a new block is added to the blockchain, it will not be removed. The block records the record data submitted by the nodes in the blockchain system.
[0127] In some embodiments, the block structure can be Figure 9 In the structure shown, each block includes the hash value of the transaction records stored in the block (the hash value of the current block) and the hash value of the previous block. Blocks are connected by hash values to form a blockchain. In addition, blocks may also include information such as the timestamp of the block's generation. The blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each data block contains relevant information used to verify the validity of the information (anti-counterfeiting) and generate the next block.
[0128] As can be seen from the technical solutions provided in the embodiments of this specification, when an application runs abnormally, the system architecture layer corresponding to the abnormality is determined, and different processing strategies are adopted for abnormalities at different layers; for application layer abnormalities, corresponding processing strategies are adopted according to the abnormality category; for local framework layer abnormalities, the application is restored to normal by modifying the current value of the register. By adopting the technical solution of this application, hierarchical recovery measures are taken for application abnormalities, which reduces the occurrence of application crashes and improves the operating stability of the application, thereby reducing users' perception of abnormalities and reducing user churn of the application.
[0129] The present application also provides a device for processing application exceptions, such as Figure 10 As shown, the device includes:
[0130] The status monitoring module 1010 is used to monitor the running status of the application program;
[0131] The system architecture layer determination module 1020 is used to determine the system architecture layer corresponding to the abnormality when the application program runs abnormally;
[0132] Category determination module 1030, for determining the category to which the exception belongs when the exception is located at the application layer;
[0133] A processing strategy determination module 1040 is used to determine an exception processing strategy based on the category to which the exception belongs;
[0134] The signal monitoring module 1050 is used to monitor the signal in the exception through the signal processing function when the exception is located in the local framework layer;
[0135] The current value acquisition module 1060 is used to obtain the current value of the target register when the exception includes the target signal;
[0136] The current value adjustment module 1070 is used to adjust the current value of the target register to a safe value so that the application program can run normally.
[0137] In some embodiments, the processing strategy determination module may include:
[0138] A first processing module, configured to, when the exception is insufficient memory, clean up the memory cache and ignore the exception;
[0139] A second processing module is configured to close the abnormal plug-in when the abnormality is a link error;
[0140] The third processing module is configured to restart the application and jump to a target page when the exception is a blacklist exception, where the target page is the page before the application is restarted.
[0141] In some embodiments, the second processing module may include:
[0142] an exception stack information determining unit, configured to determine the exception stack information corresponding to the exception when the exception is a link error;
[0143] an abnormal plug-in determining unit, configured to determine an abnormal plug-in according to the abnormal stack information;
[0144] The abnormal plug-in closing unit is used to close the abnormal plug-in.
[0145] In some embodiments, when the exception is located at the application layer and the category to which the exception belongs cannot be determined, the apparatus may further include:
[0146] A target thread determination module is used to call a system application program interface to determine a target thread corresponding to the exception;
[0147] A first judging module, configured to judge whether the target thread includes a message processing class;
[0148] A second judgment module is used to judge whether the target thread is a main thread if the target thread includes a message processing class;
[0149] A current page closing module, configured to close the current page corresponding to the target thread if the target thread is the main thread;
[0150] The first target thread running module is configured to continue running the target thread if the target thread is a non-main thread.
[0151] In some embodiments, if the target thread does not include a message processing class, the apparatus may further include:
[0152] An abnormal thread judgment module is used to judge whether the target thread is an abnormal thread;
[0153] An abnormal thread closing module, configured to close the abnormal thread if the target thread is an abnormal thread;
[0154] The second target thread running module is configured to continue running the target thread if the target thread is a non-exceptional thread.
[0155] In some embodiments, the current value acquisition module may include:
[0156] a context information acquiring unit, configured to acquire context information of the anomaly when the anomaly includes a target signal;
[0157] A current value acquisition unit is used to acquire the current value of the target register according to the context information of the exception.
[0158] In some embodiments, the apparatus may further include:
[0159] The call stack backtracking module is used to backtrack the call stack of the exception through the context information of the exception.
[0160] In some embodiments, the current value adjustment module may include:
[0161] The current value adjustment unit is used to adjust the value of the target register to a safe value through the call stack so that the application program can run normally.
[0162] The device and method embodiments in the device embodiment are based on the same inventive concept.
[0163] An embodiment of the present application provides a device for processing application exceptions, the device including a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or at least one program being loaded and executed by the processor to implement a method for processing application exceptions as provided in the above-mentioned method embodiment.
[0164] An embodiment of the present application also provides a computer-readable storage medium, which can be set in a terminal to store at least one instruction or at least one program related to a method for handling an application exception in a method embodiment. The at least one instruction or at least one program is loaded and executed by the processor to implement the method for handling an application exception provided in the above method embodiment.
[0165] Optionally, in the embodiments of this specification, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media that can store program code, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0166] The memory of the embodiment of this specification can be used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required for functions, etc.; the data storage area can store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor with access to the memory.
[0167] The embodiment of the method for handling application exceptions provided in the embodiment of the present application can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Taking running on a server as an example, Figure 11 This is a hardware structure diagram of a server of a method for handling application exceptions provided in an embodiment of the present application. Figure 11As shown, the server 1100 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 1110 (the processor 1110 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 1130 for storing data, and one or more storage media 1120 (such as one or more mass storage devices) for storing application programs 1123 or data 1122. Among them, the memory 1130 and the storage medium 1120 can be temporary storage or permanent storage. The program stored in the storage medium 1120 may include one or more modules, each module may include a series of instruction operations on the server. Furthermore, the central processing unit 1110 may be configured to communicate with the storage medium 1120 to execute a series of instruction operations in the storage medium 1120 on the server 1100. The server 1100 may also include one or more power supplies 1160, one or more wired or wireless network interfaces 1150, one or more input and output interfaces 1140, and / or one or more operating systems 1121, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0168] The input / output interface 1140 can be used to receive or send data via a network. Specific examples of the aforementioned network may include a wireless network provided by the communication provider of the server 1100. In one embodiment, the input / output interface 1140 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the input / output interface 1140 can be a radio frequency (RF) module for wireless communication with the Internet.
[0169] It can be understood by those skilled in the art that Figure 11 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 11 More or fewer components than shown, or with Figure 11 Different configurations shown.
[0170] The present application provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations described above.
[0171] As can be seen from the embodiments of the application exception processing method, device, equipment or storage medium provided by the present application, when an application runs abnormally, the system architecture layer corresponding to the exception is determined, and different processing strategies are adopted for exceptions at different layers; for application layer exceptions, corresponding processing strategies are adopted according to the exception category; for local framework layer exceptions, the application is restored to normal by modifying the current value of the register. By adopting the technical solution of the present application, hierarchical recovery measures are taken for application exceptions, which reduces the flash back of the application and improves the running stability of the application, thereby reducing the user's perception of the exception and reducing the user loss of the application.
[0172] It should be noted that the order of the embodiments of the present application described above is for descriptive purposes only and does not represent the superiority or inferiority of the embodiments. The above description is of specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0173] The various embodiments in this specification are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the device, equipment, and storage medium embodiments are generally similar to the method embodiments, so their descriptions are relatively simplified. For relevant portions, refer to the descriptions of the method embodiments.
[0174] Those skilled in the art will appreciate that all or part of the steps for implementing the above embodiments may be accomplished by hardware, or by programs instructing related hardware to accomplish the steps. The programs may be stored in a computer storage medium, and the above-mentioned storage medium may be a read-only memory, a disk, or an optical disk, etc.
[0175] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A method for handling application exceptions, characterized in that: The method comprises: Monitor the running status of the application; When the application program runs abnormally, determining the system architecture layer corresponding to the abnormality; When the anomaly is located at the application layer, determining the category to which the anomaly belongs; Determining a handling strategy for the exception based on the category to which the exception belongs; When the exception is located in the application layer and the category to which the exception belongs cannot be determined, calling a system application program interface to determine a target thread corresponding to the exception; Determine whether the target thread includes a message processing class; If the target thread includes a message processing class, determining whether the target thread is a main thread; If the target thread is the main thread, close the current page corresponding to the target thread; If the target thread is not the main thread, continue to run the target thread; When the exception is located in the local framework layer, monitoring the signal in the exception through the signal processing function; When the exception includes a target signal, obtaining a current value of a target register; The current value of the target register is adjusted to a safe value so that the application program can run normally.
2. The method according to claim 1, characterized in that Determining a handling strategy for the exception according to the category to which the exception belongs includes: When the exception is insufficient memory, clean up the memory cache and ignore the exception; When the exception is a link error, close the exception plug-in; When the exception is an exception in the blacklist, the application is restarted and the page is redirected to the target page, where the target page is the page before the application is restarted.
3. The method according to claim 2, characterized in that When the exception is a link error, closing the exception plug-in includes: When the exception is a link error, determining exception stack information corresponding to the exception; Determine the abnormal plug-in according to the abnormal stack information; Close the abnormal plug-in.
4. The method according to claim 1, wherein If the target thread does not include a message processing class, the method further includes: Determine whether the target thread is an abnormal thread; If the target thread is an abnormal thread, shut down the abnormal thread; If the target thread is a non-exceptional thread, continue to run the target thread.
5. The method according to claim 1, wherein When the exception includes a target signal, obtaining the current value of the target register includes: When the exception includes a target signal, obtaining context information of the exception; According to the context information of the exception, a current value of the target register is obtained.
6. The method according to claim 1, characterized in that Before the step of adjusting the current value of the target register to a safe value so that the application program can run normally, the method further includes: Backtracking the call stack of the exception through the context information of the exception; The adjusting the current value of the target register to a safe value so that the application program can run normally includes: The value of the target register is adjusted to a safe value through the call stack, so that the application program can run normally.
7. A device for processing application exceptions, characterized in that: The device comprises: Status monitoring module, used to monitor the running status of the application; A system architecture layer determination module, configured to determine the system architecture layer corresponding to the abnormality when the application program runs abnormally; A category determination module, configured to determine the category to which the exception belongs when the exception is located at the application layer; A processing strategy determination module, configured to determine a processing strategy for the exception according to the category to which the exception belongs; A signal monitoring module, configured to monitor the signal in the exception through a signal processing function when the exception is located in the local framework layer; a current value acquisition module, configured to acquire a current value of a target register when the exception includes a target signal; a current value adjustment module, configured to adjust the current value of the target register to a safe value so as to enable the application to run normally; When the exception is located at the application layer and the category to which the exception belongs cannot be determined, the apparatus further includes: A target thread determination module is used to call a system application program interface to determine a target thread corresponding to the exception; A first judging module, configured to judge whether the target thread includes a message processing class; A second judgment module is used to judge whether the target thread is a main thread if the target thread includes a message processing class; A current page closing module, configured to close the current page corresponding to the target thread if the target thread is the main thread; The first target thread running module is configured to continue running the target thread if the target thread is a non-main thread.
8. The device according to claim 7, characterized in that The processing strategy determination module includes: A first processing module, configured to, when the exception is insufficient memory, clean up the memory cache and ignore the exception; A second processing module is configured to close the abnormal plug-in when the abnormality is a link error; The third processing module is configured to restart the application and jump to a target page when the exception is a blacklist exception, where the target page is the page before the application is restarted.
9. The device according to claim 8, characterized in that The second processing module includes: an exception stack information determining unit, configured to determine the exception stack information corresponding to the exception when the exception is a link error; an abnormal plug-in determining unit, configured to determine an abnormal plug-in according to the abnormal stack information; The abnormal plug-in closing unit is used to close the abnormal plug-in.
10. The device according to claim 7, characterized in that If the target thread does not include a message processing class, the device further includes: An abnormal thread judgment module is used to judge whether the target thread is an abnormal thread; An abnormal thread closing module, configured to close the abnormal thread if the target thread is an abnormal thread; The second target thread running module is configured to continue running the target thread if the target thread is a non-exceptional thread.
11. The device according to claim 7, characterized in that The current value acquisition module includes: a context information acquiring unit, configured to acquire context information of the anomaly when the anomaly includes a target signal; A current value acquisition unit is used to acquire the current value of the target register according to the context information of the exception.
12. The device according to claim 7, characterized in that The device further comprises: A call stack backtracking module, configured to backtrack the call stack of the exception using the context information of the exception; The current value adjustment module includes: The current value adjustment unit is used to adjust the value of the target register to a safe value through the call stack so that the application program can run normally.
13. A device for processing application exceptions, characterized in that: The device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the method for handling application exceptions as described in any one of claims 1-6.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the method for handling application exceptions according to any one of claims 1 to 6.
Citation Information
Patent Citations
Virtual machine internal fault processing method, device and system
CN102902599A
Fuzzy testing method and system for Android applications
CN106155877A