Skip to content

Fix signed integer overflow #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2023
Merged

Conversation

Totktonada
Copy link
Member

A cast of the unsigned value 2^32-1 to int has implementation defined behavior, see n1256, 6.3.1.3.3).

Sketch:

lua_pop(L, <uint32_t> 0)
--(macro expansion)--
lua_settop(L, (int)<uint32_t> -0-1)
--(constant folding)--
lua_settop(L, (int)<uint32_t> 2^32-1)
--(UB cast to int)--
lua_settop(L, <int>implementation defined value, usually -1)

See all the details in tarantool/tarantool#8453

@Totktonada
Copy link
Member Author

#33 is filed regarding CI fails on Linux.

A cast of the unsigned value 2^32-1 to `int` has implementation defined
behavior, see n1256, 6.3.1.3.3).

Sketch:

```
lua_pop(L, <uint32_t> 0)
--(macro expansion)--
lua_settop(L, (int)<uint32_t> -0-1)
--(constant folding)--
lua_settop(L, (int)<uint32_t> 2^32-1)
--(UB cast to int)--
lua_settop(L, <int>implementation defined value, usually -1)
```

See all the details in tarantool/tarantool#8453
@Totktonada Totktonada force-pushed the fix-signed-integer-overflow branch from 9c160b5 to 925e4c9 Compare March 18, 2023 02:06
@Totktonada
Copy link
Member Author

#33 is filed regarding CI fails on Linux.

It is solved now.

Copy link

@Buristan Buristan left a comment

Choose a reason for hiding this comment

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

Hi, Alexander!
Thanks for the patch!
LGTM!

@Buristan Buristan assigned Totktonada and unassigned Buristan Mar 18, 2023
@Totktonada Totktonada merged commit a3b8695 into master Mar 20, 2023
@Totktonada Totktonada deleted the fix-signed-integer-overflow branch March 20, 2023 13:46
@Totktonada Totktonada removed their assignment Mar 20, 2023
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.

2 participants