CN112925667A - Method, device and equipment for preventing SDK (software development kit) from being crashed and readable storage medium - Google Patents

Method, device and equipment for preventing SDK (software development kit) from being crashed and readable storage medium Download PDF

Info

Publication number
CN112925667A
CN112925667A CN202110335054.3A CN202110335054A CN112925667A CN 112925667 A CN112925667 A CN 112925667A CN 202110335054 A CN202110335054 A CN 202110335054A CN 112925667 A CN112925667 A CN 112925667A
Authority
CN
China
Prior art keywords
sdk
data
value data
key value
abnormal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110335054.3A
Other languages
Chinese (zh)
Other versions
CN112925667B (en
Inventor
杨明涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202110335054.3A priority Critical patent/CN112925667B/en
Publication of CN112925667A publication Critical patent/CN112925667A/en
Application granted granted Critical
Publication of CN112925667B publication Critical patent/CN112925667B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/004Error avoidance

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Storage Device Security (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention provides a method, a device, equipment and a readable storage medium for preventing a Software Development Kit (SDK) from being crashed, which can be applied to the technical field of computer application, and the method for preventing the SDK from being crashed can comprise the following steps: key value data is obtained, wherein the key value data is generated in response to an SDK calling instruction; judging whether the key value data accords with a preset abnormal data type; if yes, replacing the original processing object with an abnormal processing object, detecting data with null values in the key value data through the abnormal processing object, and removing the data with null values. The method, the device, the equipment and the readable storage medium for preventing the SDK crash of the software development kit provided by the embodiment of the invention can prevent the crash, reduce the occurrence of the crash and avoid the problem that the existing crash is difficult to process and even cannot be realized.

Description

Method, device and equipment for preventing SDK (software development kit) from being crashed and readable storage medium
Technical Field
The present invention relates to the field of computer application technologies, and in particular, to a method, an apparatus, a device, and a readable storage medium for preventing an SDK crash.
Background
In the process of manufacturing a Software Development Kit (SDK), portability of the SDK, low coupling with other program codes, stability and the like need to be considered, and a crash handling mechanism for the SDK is needed to achieve the purpose.
The code closure of the SDK results in that during use, the user of the SDK cannot see enough rich debugging information as the source code debugging. For example, the user of the SDK calls the SDK during the running of a program, and when the SDK crashes to cause the program to crash, the user of the SDK debugs for the crash, and only the stack information and some unknown assembly codes of the SDK can be seen. Thus, when the SDK crashes, it is difficult or even impossible to debug the SDK to locate and repair the crash.
Disclosure of Invention
Embodiments of the present invention provide a processing method, an apparatus, a device, and a readable storage medium for preventing an SDK crash, so as to prevent a crash, reduce the occurrence of a crash, and avoid the situation that it is difficult or even impossible to process an already-occurring crash. The specific technical scheme is as follows:
in a first aspect of the present invention, there is provided a method for preventing a software development kit SDK from crashing, including:
key value data is obtained, wherein the key value data is generated in response to an SDK calling instruction;
judging whether the key value data accords with a preset abnormal data type;
if so, replacing the original processing object with an abnormal processing object, detecting data with null values in the key value data through the abnormal processing object, and removing the data with null values.
Optionally, before replacing the original processing object with an exception processing object and processing the key-value data, the method further includes:
and creating an exception handling object corresponding to the exception type with the data value being null.
Optionally, after determining that the key-value data conforms to the preset abnormal data type, the method further includes:
acquiring stack information in the SDK calling process in response to an SDK calling instruction;
screening out function execution stack information corresponding to the key value data from the stack information in a regular matching mode, wherein the function execution stack information is used for indicating the calling process of the SDK;
and positioning a problem code based on the function execution stack information, wherein the problem code is an abnormal code in the corresponding SDK when the key value data is generated.
Optionally, the method further includes:
determining identification information corresponding to the SDK calling instruction; the identification information comprises version information of the SDK and equipment information of equipment calling the SDK;
and taking the identification information as a key word, taking the position information of the question code as a value corresponding to the key word, and storing the key word and the position information of the question code.
In a second aspect of the present invention, there is provided an apparatus for preventing a software development kit SDK from crashing, including:
the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring key value data, and the key value data is data generated in response to an SDK calling instruction;
the judging module is used for judging whether the key value data accords with the preset abnormal data type;
the replacing module is used for replacing the original processing object with the abnormal processing object if the original processing object is the abnormal processing object;
and the processing module is used for detecting the data with the null value in the key value data through the exception handling object and removing the data with the null value.
Optionally, the apparatus further comprises:
and the creating module is used for creating the abnormal processing object corresponding to the abnormal type with the null data value before replacing the original processing object with the abnormal processing object and processing the key value data.
Optionally, the apparatus further comprises:
the second acquisition module is used for acquiring stack information in the SDK calling process in response to an SDK calling instruction after judging that the key value data accord with the preset abnormal data type;
the screening module is used for screening out function execution stack information corresponding to the key value data from the stack information in a regular matching mode, wherein the function execution stack information is used for indicating the calling process of the SDK;
and the positioning module is used for positioning a problem code based on the function execution stack information, wherein the problem code is an abnormal code in the SDK corresponding to the key value data when the key value data is generated.
Optionally, the apparatus further comprises:
the determining module is used for determining the identification information corresponding to the SDK calling instruction; the identification information comprises version information of the SDK and equipment information of equipment calling the SDK;
and the storage module is used for taking the identification information as a keyword, taking the position information of the question code as a value corresponding to the keyword, and storing the keyword and the position information of the question code.
In a third aspect of the present invention, an apparatus for preventing a software development kit SDK from crashing is provided, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of the first aspect when executing the program stored in the memory.
An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method steps in the first aspect.
In a further embodiment of the present invention, there is also provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method steps of the first aspect described above.
According to the processing method, the device, the equipment and the readable storage medium for the SDK crash, after key value data are obtained, the key value data are generated in response to an SDK calling instruction; judging whether the key value data accords with a preset abnormal data type; and if the key breaking value data accords with the preset abnormal data type, namely, judging that the abnormality occurs, replacing the original processing object with an abnormal processing object, detecting data with null values in the key value data through the abnormal processing object, and removing the data with null values. Therefore, when the SDK is abnormal, the key value data which accord with the preset abnormal data type is processed, the abnormity can be captured and processed aiming at the abnormity through the abnormity processing object before the SDK is broken down, the SDK is prevented from being broken down, and the breakage can be reduced. Before the SDK is crashed, the exception is processed, so that the problem that the processing is carried out on the crashed exception after the crash occurs, and the problem that the processing is difficult or even impossible is solved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
FIG. 1 is a flowchart of a method for preventing an SDK crash according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the message forwarding mechanism of Objective-C;
FIG. 3 is a schematic diagram illustrating an application of the method for preventing an SDK crash according to an embodiment of the present invention;
FIG. 4 is a flow chart of locating problem codes in an embodiment of the present invention;
FIG. 5 is a flowchart of storing location information of a question code according to an embodiment of the present invention;
FIG. 6 is a schematic diagram illustrating another application of the method for preventing an SDK crash according to the embodiment of the present invention;
FIG. 7 is a schematic structural diagram of an apparatus for preventing an SDK crash according to an embodiment of the present invention;
FIG. 8 is a schematic structural diagram of an apparatus for preventing an SDK crash according to an embodiment of the present invention;
FIG. 9 is a schematic structural diagram of an apparatus for preventing an SDK crash according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of an SDK crash processing apparatus according to another embodiment of the present invention;
fig. 11 is a schematic structural diagram of an apparatus for preventing an SDK crash according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.
In the embodiment of the invention, before the SDK crashes, when the SDK is detected to be abnormal, the abnormal condition is captured and processed aiming at the abnormal condition, so that the crash can be prevented and the crash can be reduced. The problem that the processing is difficult or even impossible for the crash which has already occurred can be avoided.
The method for preventing the SDK from being crashed provided by the embodiment of the invention can be applied to various SDK calling processes, such as the process of calling the SDK at the program development stage and the process of calling the SDK at the program online stage. For example, in the program development phase, an SDK user may call the SDK, and the SDK may crash in some cases, so that the program cannot run normally. In the embodiment of the invention, in the program development stage, when the SDK is detected to be abnormal before the SDK crashes, the abnormal condition is captured and processed aiming at the abnormal condition, so as to prevent the crash and reduce the occurrence of the crash.
In the stage that the program is on-line (which can also be understood as a development completion release stage), such as the stage that the APP of the application program is on-line, the SDK user may also invoke the SDK, and various usage scenarios of the APP user may cause the SDK to crash.
The embodiment of the invention does not adopt a third-party detection tool to capture the crash, but processes the abnormity before the crash occurs to prevent the crash, and can also be understood as interception crash, so that the situation that a producer of the SDK uses the same third-party tool to cause file repetition and the principle of low coupling of the SDK is violated can be avoided. And the user does not need to be consulted, so that the situation that an operator contacts the user, obtains a scene of collapse by recording a video or an operation instruction and forwards the scene to a developer to reproduce a positioning code, the influence on the positioning speed is avoided, the communication cost is reduced, the positioning efficiency is improved, and the user experience is improved.
In addition, in the embodiment of the invention, only information aiming at the abnormity can be fed back to a developer in the program development stage and is not reported to the server; and when the program is on-line, the information aiming at the abnormity is fed back to the developer and reported to the server. Thus, the server stress can be reduced.
The following describes the method for preventing SDK crash provided by the embodiment of the present invention in detail.
The method for preventing the SDK crash provided by the embodiment of the invention can be applied to electronic equipment, wherein the electronic equipment can comprise a server, a terminal and the like. Specifically, the electronic device may include a device of the SDK provider, a device of the SDK consumer, and the like.
The method for preventing the SDK crash provided by the embodiment of the invention can comprise the following steps:
key value data is obtained, wherein the key value data is generated in response to an SDK calling instruction;
judging whether the key value data accords with a preset abnormal data type;
if yes, replacing the original processing object with an abnormal processing object, detecting data with null values in the key value data through the abnormal processing object, and removing the data with null values.
In the embodiment of the invention, after key value data are obtained, whether the key value data accord with the preset abnormal data type is judged; and if the key breaking value data accords with the preset abnormal data type, replacing the original processing object with an abnormal processing object, detecting data with a null value in the key value data through the abnormal processing object, and removing the data with the null value. Therefore, when the SDK is abnormal, the key value data which accord with the preset abnormal data type is processed, the abnormity can be captured and processed aiming at the abnormity through the abnormity processing object before the SDK is broken down, the SDK is prevented from being broken down, and the breakage can be reduced. Before the SDK is crashed, the exception is processed, so that the problem that the processing is carried out on the crashed exception after the crash occurs, and the problem that the processing is difficult or even impossible is solved.
Fig. 1 is a flowchart of a method for preventing an SDK crash according to an embodiment of the present invention, and referring to fig. 1, the method for preventing an SDK crash according to an embodiment of the present invention may include:
s101, key value data are obtained.
The key value data is data generated in response to an SDK call instruction.
The SDK call instruction is an instruction to call the SDK.
In the SDK calling process, an SDK calling instruction may be sent, and key value data may be generated in response to the SDK calling instruction.
And S102, judging whether the key value data accord with the preset abnormal data type.
If yes, go to S103. That is, when the key-value data matches the predetermined abnormal data type, S103 is executed.
According to the historical abnormal behavior, the characteristics of the key value data corresponding to the abnormal behavior can be analyzed, and the type of the key value data corresponding to the abnormal behavior in the historical abnormal behavior can be determined to be the abnormal data type.
After the key value data is obtained, the key value data can be matched with a preset abnormal data type, and if the key value data is matched with the preset abnormal data type, the key breaking value data can be understood to accord with the preset abnormal data type. Whether the key value data is matched with the preset abnormal data type or not can be determined through the contact degree of the key value data and the preset abnormal data type, for example, if the contact degree of the key value data and the preset abnormal data type reaches a preset value, such as 90% or 80%, the key value data can be determined to be matched with the preset abnormal data type.
S103, replacing the original processing object with an abnormal processing object, detecting data with null values in the key value data through the abnormal processing object, and removing the data with null values.
The original processing object is a non-exception processing object, and may be, for example, a message forwarding processing object, and so on.
An exception handling object may be understood as an object that encapsulates method steps for exception handling. By the exception handling object, an exception can be captured and handled against the exception to prevent the SDK from crashing.
After key value data are obtained, judging whether the key value data accord with a preset abnormal data type; and if the key breaking value data accords with the preset abnormal data type, replacing the original processing object with an abnormal processing object, detecting data with a null value in the key value data through the abnormal processing object, and removing the data with the null value. Therefore, when the SDK is abnormal, the key value data which accord with the preset abnormal data type is processed, the abnormity can be captured and processed aiming at the abnormity through the abnormity processing object before the SDK is broken down, the SDK is prevented from being broken down, and the breakage can be reduced. Before the SDK is crashed, the exception is processed, so that the problem that the processing is carried out on the crashed exception after the crash occurs, and the problem that the processing is difficult or even impossible is solved.
Specifically, the exception handling object may encapsulate an exception handling mechanism for handling the null object, replace the original handling object with the exception handling object, that is, detect data with null value in the key value data through the exception handling object, and remove the data with null value. Thus, the empty object can be prevented from being crashed.
In an optional embodiment, replacing the original processing object with an exception processing object in S103, before processing the key-value data, the method may further include:
and creating an exception handling object corresponding to the exception type with the data value being null.
Before replacing the original processing object with the exception processing object, acquiring the exception processing object, and replacing the original processing object with the exception processing object.
In one implementation, the exception handling object may be a NSException. Then a crash can be preventively treated by the nature of the NSException.
In the embodiment of the invention, classification of the NSObject system class can be created; exception handling objects are registered in the classification of the NSObject System class. In this way, the registered exception handling object in the NSObject system class can be called, and through the registered exception handling object, the exception is captured and handled to prevent the SDK from crashing.
And when detecting that the SDK is abnormal, forwarding the key value data to the abnormal processing object through a runtime message forwarding mechanism. Specifically, a forwardtagrgetfirector function is called, and key-value data is forwarded to the exception handling object.
It is also understood that, in this classification, method exchange is performed to exchange an original processing object for a method executed by an exception processing object. The exception processing is performed by the exception processing object.
In an implementation manner, NSException may be used to capture an exception, and a message detection mechanism is used to perform exception handling, that is, interception of a crash is performed to achieve crash prevention. Handling exceptions by the nature of NSException can be achieved as follows:
the function information carried by NSException may include the name of the exception, the reason for the exception, and other information related to the exception. In an implementation manner, a crash information can be created according to the function information carried by the NSException, a crash condition simulation is performed, the occurrence of the crash is simulated, and information related to the crash can be directly and clearly seen. The crash can be preventively processed based on this information.
In one particular example. A common method for quickly creating a dictionary @ { key: value }; the called method is dictionary Withoobjects, forKeys, count; the method may cause a crash because either the key in the key array or the value in objects is empty. This can be achieved, for example, by the following procedure:
when an exception occurs, analyzing the information carried by the exception NSException, forwarding the key value data corresponding to the exception to an exception handling object, and removing the data with the value in the key array or the value in the objects being empty through the exception handling object, so that the empty object is removed, the occurrence of crash is prevented, and the function call can be normally performed after the exception is repaired.
In an optional embodiment of the present invention, in the SDK invoking process, when detecting that the SDK is abnormal, the key value data may be forwarded to the created exception handling object through a runtime message forwarding mechanism, where the exception indicates that the object has not crashed yet; by exception handling the object, exceptions are captured and handled against the exceptions to prevent SDK crashes.
The message forwarding mechanism of Objective-C (general, high-level, object-oriented programming language) is explained first. As shown in fig. 2, when a function method is not found, the runtime message handling mechanism is remedied by the following steps:
calling a resolveInstanceMethod to cause a class to add a function; calling forwardding targetforeselect to call another object to execute the function; calling forwardlnvocation (function executor) calls the flexible way to execute the target function in other ways.
When the message cannot be processed in the above manner, a crash (crash) occurs.
In the embodiment of the invention, an exception handling mechanism is added by using a runtime message handling mechanism. And specifically considers that a resolveInstanceMethod function in a runtime message processing mechanism needs to dynamically add a method in itself, and this method is redundant for classes in itself, which also violates the principle of more invariability of the code. The forwardlnvocation function forwards messages to multiple objects via nsaction, which is expensive and requires the creation of nsaction objects. And the forwardingTargetForSelector forwards the message to an object, so that the cost is low. Therefore, in the embodiment of the present invention, an exception handling mechanism is added in the second step of the runtime message handling mechanism, that is, in the process of calling the forwardtagrgetforceptor to make another object execute the function, so that when an SDK is abnormal, the exception is captured and handled against the exception, so as to prevent a crash and reduce the occurrence of the crash.
Key value data can be obtained, wherein the key value data is data generated in response to an SDK calling instruction; judging whether the key value data accords with a preset abnormal data type; if yes, forwarding the key value data to the established exception handling object through a runtime message forwarding mechanism so as to replace the original handling object with the exception handling object, detecting data with null values in the key value data through the exception handling object, and removing the data with null values.
Specifically, when the calling of the resolveInstanceMethod function fails to process the message, the forwarding targetforwarder function is called, and the key-value data is forwarded to the created exception handling object.
Since the resolveInstanceMethod function in the runtime message processing mechanism needs to dynamically add a method in itself, which is redundant for classes in itself, this violates the principle of more invariability of the code. The forwardlnvocation function forwards messages to multiple objects via nsaction, which is expensive and requires the creation of nsaction objects. And the forwardingTargetForSelector forwards the key-value data to an object, so that the overhead is low. Therefore, in the embodiment of the present invention, an exception handling mechanism may be added in the second step of the runtime message handling mechanism, that is, in the process of calling forwardtagrgetfonsector to make another object execute the function, so that the overhead can be reduced.
Therefore, before the SDK is crashed, the created exception handling object is used for capturing the exception and handling the exception, namely, the SDK is prevented from being crashed, and the occurrence of crash can be reduced. Before the SDK is crashed, the exception is processed, so that the problem that the processing is carried out on the crashed exception after the crash occurs, and the problem that the processing is difficult or even impossible is solved.
Meanwhile, reliable crash prevention and reporting can be provided for various SDKs, and the stability and experience of the SDKs are improved. The privacy positioning problem can be solved in advance on the premise that the client operates normally and stably.
Fig. 3 is a schematic diagram of an application of the method for preventing an SDK crash according to the embodiment of the present invention. Referring to fig. 3, a NSObject system class is created for which a classification is created; the message forwarding is performed by calling a forwarding targetForSector function, that is, key value data is sent to a classification created for the NSObject system class, the classification of the NSObject system class registers NSException, runtime methods are exchanged, and NSException can be understood as an exchanged classification method. After the NSObject system class is called, a classification method under classification created by the NSObject system class can be executed, and in the classification method, prevention processing is executed through NSException, namely exception processing is carried out, so that crash is prevented.
In an optional embodiment, after determining that the key-value data conforms to the preset abnormal data type, as shown in fig. 4, the embodiment of the present invention may further include:
s401, stack information in the process of calling the SDK in response to the SDK calling instruction is obtained.
An SDK may also be understood as a package of code that actually generates a mach o under various processors, each section (section) of the mach o containing different packet data.
The stack information may include code to implement the SDK.
And acquiring stack information in the process of calling the SDK in response to the SDK calling instruction from all stack information corresponding to the SDK.
S402, screening out function execution stack information corresponding to the key value data from the stack information in a regular matching mode.
The function execution stack information is used to indicate the call flow of the SDK.
There are many other system functions for the stack information, and the acquired stack information may be filtered in order to obtain function execution stack information indicating the SDK call flow.
All functions may be filtered first using a regular matching approach. For example, the canonical criteria of- [ class name method name ] or + [ class name method name ] are used to screen out all functions. And then, deleting the function corresponding to the key value data from all the screened functions.
S403, positioning the problem code based on the function execution stack information.
The problem code is an exception code in the corresponding SDK when the key-value data is generated.
Locating the problem code may be obtaining location information for the problem code, such as line number code, and so on.
Problem code can be located based on function execution stack information through NSException. The specific process is as follows:
capturing an exception through a mainCallStackSymbolMsg function; obtaining abnormal stack information through NSRegularExpression; circularly traversing abnormal stack information, and judging to obtain an abnormal class name through a regular expression; the function and cause of the anomaly are obtained by tempCallStackSymbolMsg. And analyzing by combining a MachO symbol table, and positioning the abnormal code.
In the embodiment of the invention, the pre-created message processing object is called in the message forwarding mechanism to process the exception, and the problem code is positioned before the crash happens based on the stack information, so that the problem that the code is difficult to position due to the SDK closed line can be avoided.
On the basis of the embodiment shown in fig. 4, as shown in fig. 5, the embodiment of the present invention may further include:
s404, determining the identification information corresponding to the SDK calling instruction.
The identification information includes version information of the SDK and device information of a device that called the SDK.
S405, stores the keyword and the position information of the question code, using the identification information as the keyword and the position information of the question code as the value corresponding to the keyword.
I.e. storing the location information of the problem code in the form of key-value pairs.
In one implementation, the location information of the problem code and the problem code may also be stored simultaneously.
Further, the cause of the abnormality may be analyzed based on the obtained function execution stack information, and the cause of the abnormality may be stored while the positional information of the problem code is stored.
In one implementation, the keyword and the location information of the problem code corresponding to the keyword may be stored by a hash table.
The key, i.e., the keyword, may be SDK version + device system + idfa (advertisement identifier) or idfv (device unique identification), where both idfa and idfv may be used to represent device uniqueness.
In one implementation, the hash table stores only one piece of exception information, and does not add keys to the same piece of exception information. One anomaly information can be understood as identification information obtained when an anomaly occurs and position information of a corresponding problem code.
In an alternative embodiment, the exception information may be stored in the memory of the electronic device. When the program is in a program development stage, setting Documents (files) of the APP to be accessible, writing the corresponding hash table into a disk, and deleting the key corresponding to the hash table in the memory after writing.
In an optional embodiment, when the SDK calling process is a process of calling the SDK in the program development phase, the exception information is sent to the SDK provider device, so that the SDK provider repairs the SDK by using the exception information.
And judging that the SDK needs to be changed according to the detection condition, debugging the SDK, changing the SDK and the like. This process eliminates the need to upload exception information to the server.
In particular, the SDK provider may provide exception information through third party tools.
And when the SDK calling process is a process for calling the SDK in the on-line stage of the program, uploading the abnormal information to the server.
After the SDK user (which can be understood as a user) calls the SDK to implement the program online, the related information such as the program usage is stored locally in the SDK provider device, so the SDK provider cannot obtain the exception occurring in the SDK user usage process. Therefore, when the program is on-line, the exception information including the exception cause and the problem code generating the exception, that is, the exception related information is sent to the server independent of the SDK user device, so that the exception information and the like can be checked through the server.
Thus, different processing can be performed in development and distribution environments, and server pressure is relieved.
In one implementation, the impact of the uploading process on the performance of the electronic device is avoided. The method comprises the steps that a source of a souces of a main thread is monitored through RunLoop (circulation) at the time of uploading abnormal information to a server, and the souces are uploaded when the souces are monitored to be in a defaultMode (default mode). Further, the method can report single data.
The hash table needs to be cleared by setting a corresponding time period, which is generally 2 to 3 days. The process can be directly checked by the background of the server without providing data by a user.
Because the key file needs to be taken to the SDK provider first to start disk writing in the program development stage for security, the purpose of this is to protect the disk memory. And in the program release state, the SDK provider does not need to obtain the information before the key file is taken, so that the server can directly check the abnormal information.
Based on the embodiment shown in fig. 3, fig. 6 is a schematic diagram of another application of the method for preventing an SDK crash according to the embodiment of the present invention. Referring to fig. 6, in fig. 3, through NSException, an exception may be obtained, and through mach stack analysis, a classification function obtains an exception function and an exception cause, a cause of the exception, and a problem code that generates the exception, which may also be understood as a function and a cause that may cause a crash. And informing the single column according to a rule, and writing the obtained function and reason which possibly cause the crash into a hash table of the memory, wherein the single column is a global class and can only be created once, and the single column always exists in the life cycle of the program, so that the call is convenient. Then judging whether the program is on-line, if so, uploading the hash table to a server, and a developer checks abnormal information and modifies bug (bug) through a background; if the hash table is not online, for example, in a program development stage, writing the hash table into a Documents directory of a sandbox, detecting before online, and if the online detection is passed, if no bug is found, uploading the hash table to a server; and if not, in order to continuously capture the exception and process the exception, such as returning to the step of performing exception processing through NSException in the classification method.
Corresponding to the method for preventing the SDK crash provided in the foregoing embodiment, an embodiment of the present invention provides an apparatus for preventing the SDK crash, as shown in fig. 7, including:
a first obtaining module 701, configured to obtain key value data, where the key value data is data generated in response to an SDK call instruction;
a judging module 702, configured to judge whether the key-value data conforms to a preset abnormal data type;
a replacing module 703, configured to replace the original processing object with the exception processing object if the original processing object is the exception processing object;
the processing module 704 is configured to detect, by the exception handling object, data with a null value in the key-value data, and remove the data with the null value.
Optionally, as shown in fig. 8, the apparatus further includes:
the creating module 705 is configured to create an exception handling object corresponding to the exception type with a null data value before replacing the original handling object with the exception handling object and handling the key value data.
Optionally, as shown in fig. 9, the apparatus further includes:
a second obtaining module 901, configured to obtain stack information in a process of calling the SDK in response to the SDK calling instruction after determining that the key value data conforms to the preset abnormal data type;
a screening module 902, configured to screen, in a regular matching manner, function execution stack information corresponding to the key value data from the stack information, where the function execution stack information is used to indicate a call flow of the SDK;
and a positioning module 903, configured to position a problem code based on the function execution stack information, where the problem code is an abnormal code in the SDK corresponding to the key value data generated.
Optionally, as shown in fig. 10, the apparatus further includes:
a determining module 1001, configured to determine identification information corresponding to the SDK call instruction; the identification information comprises version information of the SDK and equipment information of equipment calling the SDK;
the saving module 1002 is configured to use the identification information as a keyword, use the location information of the question code as a value corresponding to the keyword, and save the keyword and the location information of the question code.
The device for preventing the SDK crash provided by the embodiment of the invention is a device applying the method for preventing the SDK crash, so that all embodiments of the method for preventing the SDK crash are suitable for the device and can achieve the same or similar beneficial effects.
An embodiment of the present invention further provides a device for preventing an SDK crash, as shown in fig. 11, including a processor 1101, a communication interface 1102, a memory 1103, and a communication bus 1104, where the processor 1101, the communication interface 1102, and the memory 1103 complete communication with each other through the communication bus 1104.
A memory 1103 for storing a computer program;
the processor 1101 is configured to implement the method steps of the method for preventing the SDK crash described above when executing the program stored in the memory 1103.
The communication bus mentioned in the above device for preventing the SDK crash may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the device for preventing the SDK crash and other devices.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In yet another embodiment provided by the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program, when being executed by a processor, implements the method steps of the method for preventing an SDK crash in the above-mentioned embodiment.
In a further embodiment provided by the present invention, there is also provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method steps of the method of preventing an SDK crash of the above embodiment.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus, the device, the computer-readable storage medium, and the computer program product embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and in relation to the description, reference may be made to some of the description of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A method for preventing Software Development Kit (SDK) crash, comprising:
key value data is obtained, wherein the key value data is generated in response to an SDK calling instruction;
judging whether the key value data accords with a preset abnormal data type;
if so, replacing the original processing object with an abnormal processing object, detecting data with null values in the key value data through the abnormal processing object, and removing the data with null values.
2. The method of claim 1, wherein prior to said replacing the original processing object with an exception processing object, processing the key-value data, the method further comprises:
and creating an exception handling object corresponding to the exception type with the data value being null.
3. The method of claim 1, wherein after determining that the key-value data conforms to the predetermined abnormal data type, the method further comprises:
acquiring stack information in the SDK calling process in response to an SDK calling instruction;
screening out function execution stack information corresponding to the key value data from the stack information in a regular matching mode, wherein the function execution stack information is used for indicating the calling process of the SDK;
and positioning a problem code based on the function execution stack information, wherein the problem code is an abnormal code in the corresponding SDK when the key value data is generated.
4. The method of claim 3, further comprising:
determining identification information corresponding to the SDK calling instruction; the identification information comprises version information of the SDK and equipment information of equipment calling the SDK;
and taking the identification information as a key word, taking the position information of the question code as a value corresponding to the key word, and storing the key word and the position information of the question code.
5. An apparatus for preventing Software Development Kit (SDK) crash, comprising:
the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring key value data, and the key value data is data generated in response to an SDK calling instruction;
the judging module is used for judging whether the key value data accords with the preset abnormal data type;
the replacing module is used for replacing the original processing object with the abnormal processing object if the original processing object is the abnormal processing object;
and the processing module is used for detecting the data with the null value in the key value data through the exception handling object and removing the data with the null value.
6. The apparatus of claim 5, further comprising:
and the creating module is used for creating the abnormal processing object corresponding to the abnormal type with the null data value before replacing the original processing object with the abnormal processing object and processing the key value data.
7. The apparatus of claim 5, further comprising:
the second acquisition module is used for acquiring stack information in the SDK calling process in response to an SDK calling instruction after judging that the key value data accord with the preset abnormal data type;
the screening module is used for screening out function execution stack information corresponding to the key value data from the stack information in a regular matching mode, wherein the function execution stack information is used for indicating the calling process of the SDK;
and the positioning module is used for positioning a problem code based on the function execution stack information, wherein the problem code is an abnormal code in the SDK corresponding to the key value data when the key value data is generated.
8. The apparatus of claim 7, further comprising:
the determining module is used for determining the identification information corresponding to the SDK calling instruction; the identification information comprises version information of the SDK and equipment information of equipment calling the SDK;
and the storage module is used for taking the identification information as a keyword, taking the position information of the question code as a value corresponding to the keyword, and storing the keyword and the position information of the question code.
9. The device for preventing the SDK crash of the software development kit is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 4 when executing a program stored in the memory.
10. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1 to 4.
CN202110335054.3A 2021-03-29 2021-03-29 Method, device and equipment for preventing SDK from crashing and readable storage medium Active CN112925667B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110335054.3A CN112925667B (en) 2021-03-29 2021-03-29 Method, device and equipment for preventing SDK from crashing and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110335054.3A CN112925667B (en) 2021-03-29 2021-03-29 Method, device and equipment for preventing SDK from crashing and readable storage medium

Publications (2)

Publication Number Publication Date
CN112925667A true CN112925667A (en) 2021-06-08
CN112925667B CN112925667B (en) 2024-03-08

Family

ID=76176401

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110335054.3A Active CN112925667B (en) 2021-03-29 2021-03-29 Method, device and equipment for preventing SDK from crashing and readable storage medium

Country Status (1)

Country Link
CN (1) CN112925667B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150261596A1 (en) * 2014-03-17 2015-09-17 Microsoft Corporation Framework for user-mode crash reporting
US20160110238A1 (en) * 2014-10-16 2016-04-21 International Business Machines Corporation Automated diagnosis of software crashes
CN107643980A (en) * 2017-08-21 2018-01-30 武汉斗鱼网络科技有限公司 A kind of method and apparatus for positioning crash info
CN108052407A (en) * 2017-12-13 2018-05-18 深圳乐信软件技术有限公司 A kind of application crash means of defence, device, equipment and storage medium
US20180181482A1 (en) * 2016-12-22 2018-06-28 SafeDK Mobile Ltd. Monitoring Activity of Software Development Kits Using Stack Trace Analysis
CN108334415A (en) * 2017-01-20 2018-07-27 百度在线网络技术(北京)有限公司 A kind of fault-tolerance processing method, device, terminal and storage medium
CN109800100A (en) * 2018-12-25 2019-05-24 福建天晴在线互动科技有限公司 A kind of method and terminal for preventing IOS project from collapsing
CN111338943A (en) * 2020-02-21 2020-06-26 北京字节跳动网络技术有限公司 Test method, test device, electronic equipment and readable storage medium
CN112052054A (en) * 2020-09-02 2020-12-08 北京奇艺世纪科技有限公司 Function calling method and device, electronic equipment and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150261596A1 (en) * 2014-03-17 2015-09-17 Microsoft Corporation Framework for user-mode crash reporting
US20160110238A1 (en) * 2014-10-16 2016-04-21 International Business Machines Corporation Automated diagnosis of software crashes
US20180181482A1 (en) * 2016-12-22 2018-06-28 SafeDK Mobile Ltd. Monitoring Activity of Software Development Kits Using Stack Trace Analysis
CN108334415A (en) * 2017-01-20 2018-07-27 百度在线网络技术(北京)有限公司 A kind of fault-tolerance processing method, device, terminal and storage medium
CN107643980A (en) * 2017-08-21 2018-01-30 武汉斗鱼网络科技有限公司 A kind of method and apparatus for positioning crash info
CN108052407A (en) * 2017-12-13 2018-05-18 深圳乐信软件技术有限公司 A kind of application crash means of defence, device, equipment and storage medium
CN109800100A (en) * 2018-12-25 2019-05-24 福建天晴在线互动科技有限公司 A kind of method and terminal for preventing IOS project from collapsing
CN111338943A (en) * 2020-02-21 2020-06-26 北京字节跳动网络技术有限公司 Test method, test device, electronic equipment and readable storage medium
CN112052054A (en) * 2020-09-02 2020-12-08 北京奇艺世纪科技有限公司 Function calling method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112925667B (en) 2024-03-08

Similar Documents

Publication Publication Date Title
CN109284269B (en) Abnormal log analysis method and device, storage medium and server
US8250543B2 (en) Software tracing
CN103699480B (en) A kind of WEB dynamic security leak detection method based on JAVA
CN107329894B (en) Application program system testing method and device and electronic equipment
CN110879781B (en) Program debugging method, device, electronic equipment and computer readable storage medium
CN113489713A (en) Network attack detection method, device, equipment and storage medium
CN110647472A (en) Breakdown information statistical method and device, computer equipment and storage medium
CN114238980B (en) Industrial control equipment vulnerability mining method, system, equipment and storage medium
US20190121985A1 (en) Detecting vulnerabilities in applications during execution
US8489938B2 (en) Diagnostic data capture in a computing environment
JP4913353B2 (en) Software operation modeling device and software operation monitoring device
CN115495424A (en) Data processing method, electronic device and computer program product
CN117076301A (en) System performance test method and device and electronic equipment
CN114328168A (en) Anomaly detection method and device, computer equipment and storage medium
CN112925667B (en) Method, device and equipment for preventing SDK from crashing and readable storage medium
CN114500249B (en) Root cause positioning method and device
CN110990179A (en) Task processing method, device and equipment
CN111752819A (en) Abnormity monitoring method, device, system, equipment and storage medium
KR102256894B1 (en) Method, Server and Computer Program for Crash Report Grouping
CN110443043B (en) Vulnerability detection method and device for android application program
CN115080012A (en) class file conflict recognition method and device, electronic equipment and storage medium
CN114021127A (en) Intrusion prevention data processing method and device, computer equipment and storage medium
CN110096281B (en) Code analysis method, analysis server, storage medium and device
CN112528331A (en) Privacy disclosure risk detection method, device and system
JP5679347B2 (en) Failure detection device, failure detection method, and program

Legal Events

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