# US 11,442,739 B2 · Exception handling

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 11,442,739 B2
- Document ID: US11442739B2
- Status: Granted
- Kind: B2
- Application number: 16/571,592
- Filed: 2019-09-16
- Published: 2021-03-18
- Granted: 2022-09-13
- Earliest claimed: 2019-09-16
- Assignees: International Business Machines Carporation
- Applicants: International Business Machines Corporation
- Inventors: Ming Ran Liu; Bao Zhang; Naijie Li; Yuan Zhai; Sean Douglas Perry
- Web page: https://patentgrep.com/patent/US11442739B2

## CPC

- G06F 9/3861: {Recovery, e.g. branch miss-prediction, exception handling (error detection or correction G06F11/00)}
- G06F 9/4812: {by interrupt, e.g. masked}
- G06F 9/542: {Event management; Broadcasting; Multicasting; Notifications}
- G06F 11/0772: {Means for error signaling, e.g. using interrupts, exception flags, dedicated error registers}
- G06F 2201/865: Monitoring of software
- G06F 2209/481: Exception handling
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Embodiments of the present disclosure relate to a method, system, and computer program product for exception handling. In some embodiments, a method is disclosed. According to the method, in response to an application throwing an exception, a target stack frame for handling the exception is detected from a call stack of the application. The call stack comprises a plurality of stack frames. One of the plurality of stack frames corresponds to a function called by the application and supports either a one-phase exception handling mechanism or a two-phase exception handling mechanism. In response to the target stack frame being detected from the call stack, the target stack frame is caused to handle the exception. In other embodiments, a system and a computer program product are disclosed.

## Claims

### Claim 1

A computer-implemented method comprising:
in response to an application throwing an exception, detecting a target stack frame for handling the exception from a call stack of the application, wherein the call stack comprises a plurality of stack frames, and wherein detecting the target stack frame comprises determining whether to perform a search of the call stack based on whether one of the plurality of stack frames supports a one-phase exception handling mechanism or a two-phase exception handling mechanism;
in response to determining that at least one of the plurality of stack frames supports the two-phase exception handling mechanism, performing a search on the call stack for
a first stack frame supporting the two-phase exception handling mechanism and capable of handling the exception, and
a second stack frame supporting the one-phase exception handling mechanism; and
in response to the target stack frame being detected from the call stack, causing the target stack frame to handle the exception.

### Claim 2 (depends on 1)

The method of claim 1, wherein detecting the target stack frame from the call stack further comprises:
in response to determining that the one of the plurality of stack frames supports the one-phase exception handling mechanism, determining whether the one of the plurality of stack frames is capable of handling the exception; and
in response to determining that the one of the plurality of stack frames is incapable of handling the exception, destructing the one of the plurality of stack frames.

### Claim 3 (depends on 1)

The method of claim 1, wherein detecting the target stack frame from the call stack further comprises:
in response to determining that the one of the plurality of stack frames supports the one-phase exception handling mechanism, determining whether the one of the plurality of stack frames is capable of handling the exception; and
in response to determining that the one of the plurality of stack frames is capable of handling the exception, determining the one of the plurality of stack frames as the target stack frame.

### Claim 4 (depends on 3)

The method of claim 3, wherein causing the target stack frame to handle the exception comprises:
causing the target stack frame to take over control of the application.

### Claim 5 (depends on 1)

The method of claim 1, wherein detecting the target stack frame from the call stack further comprises:
in response to the first stack frame being found in the call stack, determining the first stack frame as the target stack frame.

### Claim 6 (depends on 5)

The method of claim 5, wherein causing the target stack frame to handle the exception comprises:
destructing stack frames located on top of the target stack frame in the call stack; and
causing the target stack frame to take over control of the application.

### Claim 7 (depends on 5)

The method of claim 5, further comprising:
identifying a second stack frame supporting the one-phase exception handling mechanism during the search performed on the call stack.

### Claim 8 (depends on 7)

The method of claim 7, wherein detecting the target stack frame from the call stack further comprises:
in response to the first stack frame not being found in the call stack and the second stack frame being identified,
determining whether a third stack frame of the plurality of stack frames is capable of handling the exception; and
in response to determining that the third stack frame is incapable of handling the exception, destructing the third stack frame.

### Claim 9 (depends on 7)

The method of claim 7, wherein detecting the target stack frame from the call stack further comprises:
in response to the first stack frame not being found in the call stack and the second stack frame being identified,
determining whether a third stack frame of the plurality of stack frames is capable of handling the exception; and
in response to determining that the third stack frame is capable of handling the exception, determining the third stack frame as the target stack frame.

### Claim 10 (depends on 9)

The method of claim 9, wherein causing the target stack frame to handle the exception comprises causing the target stack frame to take over control of the application.

### Claim 11 (depends on 1)

The method of claim 1, further comprising:
in response to the target stack frame not being detected from the call stack, terminating the application.

### Claim 12

A system comprising:
a processing unit; and
a memory coupled to the processing unit and storing instructions thereon, the instructions, when executed by the processing unit, performing actions comprising:
in response to an application throwing an exception, detecting a target stack frame for handling the exception from a call stack of the application, wherein the call stack comprises a plurality of stack frames, and wherein detecting the target stack frame comprises determining whether to perform a search of the call stack based on whether one of the plurality of stack frames supports a one-phase exception handling mechanism or a two-phase exception handling mechanism;
in response to determining that at least one of the plurality of stack frames supports the two-phase exception handling mechanism, performing a search on the call stack for
a first stack frame supporting the two-phase exception handling mechanism and capable of handling the exception, and
a second stack frame supporting the one-phase exception handling mechanism; and
in response to the target stack frame being detected from the call stack, causing the target stack frame to handle the exception.

### Claim 13 (depends on 12)

The system of claim 12, wherein detecting the target stack frame from the call stack further comprises:
in response to determining that the one of the plurality of stack frames supports the one-phase exception handling mechanism, determining whether the one of the plurality of stack frames is capable of handling the exception;
in response to determining that the one of the plurality of stack frames is incapable of handling the exception, destructing the one of the plurality of stack frames; and
in response to determining that the one of the plurality of stack frames is capable of handling the exception, determining the one of the plurality of stack frames as the target stack frame.

### Claim 14 (depends on 13)

The system of claim 13, wherein causing the target stack frame to handle the exception comprises:
causing the target stack frame to take over control of the application.

### Claim 15 (depends on 13)

The system of claim 13, wherein detecting the target stack frame from the call stack further comprises:
in response to the first stack frame being found in the call stack, determining the first stack frame as the target stack frame.

### Claim 16 (depends on 15)

The system of claim 15, wherein causing the target stack frame to handle the exception comprises:
destructing stack frames located on top of the target stack frame in the call stack; and
causing the target stack frame to take over control of the application.

### Claim 17 (depends on 15)

The system of claim 15, wherein the actions further comprise:
identifying a second stack frame supporting the one-phase exception handling mechanism during the search performed on the call stack.

### Claim 18 (depends on 17)

The system of claim 17, wherein detecting the target stack frame from the call stack further comprises:
in response to the first stack frame not being found in the call stack and the second stack frame being identified,
determining whether a third stack frame of the plurality of stack frames is capable of handling the exception;
in response to determining that the third stack frame is incapable of handling the exception, destructing the third stack frame; and
in response to determining that the third stack frame is capable of handling the exception, determining the third stack frame as the target stack frame.

### Claim 19 (depends on 18)

The system of claim 18, wherein causing the target stack frame to handle the exception comprises:
causing the target stack frame to take over control of the application.

### Claim 20

A computer program product comprising a computer readable storage medium having program instructions embodied therewith, the program instructions executable by a processor to cause the processor to perform a method comprising:
in response to an application throwing an exception, detecting a target stack frame for handling the exception from a call stack of the application, wherein the call stack comprises a plurality of stack frames, and wherein detecting the target stack frame comprises determining whether to perform a search of the call stack based on whether one of the plurality of stack frames supports a one-phase exception handling mechanism or a two-phase exception handling mechanism;
in response to determining that at least one of the plurality of stack frames supports the two-phase exception handling mechanism, performing a search on the call stack for
a first stack frame supporting the two-phase exception handling mechanism and capable of handling the exception, and
a second stack frame supporting the one-phase exception handling mechanism; and
in response to the target stack frame being detected from the call stack, causing the target stack frame to handle the exception.
