Skip to content

Conversation

@nanasi880
Copy link
Contributor

Accepting the return value of a C setjmp macro as a variable is undefined behavior and should generally not be considered safe.

reference: https://pubs.opengroup.org/onlinepubs/009604599/functions/setjmp.html

An application shall ensure that an invocation of setjmp() appears in one of the following contexts only:
    - The entire controlling expression of a selection or iteration statement
    - One operand of a relational or equality operator with the other operand an integral constant expression, with the resulting expression being the entire controlling expression of a selection or iteration statement
    - The operand of a unary '!' operator with the resulting expression being the entire controlling expression of a selection or iteration
    - The entire expression of an expression statement (possibly cast to void)

If the invocation appears in any other context, the behavior is undefined.

It was introduced for debugging purposes in the following commit, and earlier implementations did not have this problem.
64bb59f

The implementation has been modified to conform to C standards while maintaining this debugging information where possible.
In the default case, we have given up on displaying current_stage.

@AkihiroSuda
Copy link
Member

Thanks, but please sign the commit for DCO
https://github.com/apps/dco

(run git commit -a -s --amend, and make sure that the Signed-off-by: NAME <EMAIL> line with your real name is included in the commit message)

@kolyshkin kolyshkin requested a review from cyphar March 28, 2023 16:00
@nanasi880 nanasi880 force-pushed the fix_undefined_behavior branch 3 times, most recently from bb203fb to f822750 Compare March 29, 2023 11:40
@nanasi880
Copy link
Contributor Author

Completed sign the commit for DCO.

@cyphar cyphar force-pushed the fix_undefined_behavior branch from f822750 to e451b0c Compare March 31, 2023 02:44
@kolyshkin kolyshkin force-pushed the fix_undefined_behavior branch from e451b0c to bd7b771 Compare April 7, 2023 01:02
@kolyshkin
Copy link
Contributor

Rebased for the sake of green CI

@cyphar cyphar force-pushed the fix_undefined_behavior branch from bd7b771 to 6053aea Compare April 12, 2023 04:27
Do not accept setjmp return value as variable.

Signed-off-by: Kazuki Hasegawa <nanasi880@gmail.com>
@nanasi880
Copy link
Contributor Author

CI is all green :)

Copy link
Member

@cyphar cyphar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@cyphar cyphar closed this in 1198389 Apr 12, 2023
@cyphar cyphar merged commit 1198389 into opencontainers:main Apr 12, 2023
@nanasi880 nanasi880 deleted the fix_undefined_behavior branch April 14, 2023 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants