Skip to content

Fix various UB:s reported by GCC's address sanitizer#2220

Merged
fredrik-johansson merged 4 commits intoflintlib:mainfrom
fredrik-johansson:sanity
Jan 30, 2025
Merged

Fix various UB:s reported by GCC's address sanitizer#2220
fredrik-johansson merged 4 commits intoflintlib:mainfrom
fredrik-johansson:sanity

Conversation

@fredrik-johansson
Copy link
Copy Markdown
Collaborator

@fredrik-johansson fredrik-johansson commented Jan 30, 2025

Fixes some signed integer overflows, shifts out of range for the type, etc.

All instances I fixed looked completely harmless (wraparound arithmetic did the right thing) but this will cut down on the noise if someone wants to use the address sanitizer to hunt down more serious bugs.

There are plenty of these left, notably in the mpoly modules where a more careful look might be needed. Also arb_dot and its variants have some signed integer overflows that are harmless because they only occur when the result will not be used in the end. I'm not sure how to fix those cleanly.

Also adds FLINT_UABS for safely converting an slong to its absolute value as a ulong.

@fredrik-johansson fredrik-johansson merged commit 1e7f305 into flintlib:main Jan 30, 2025
@fredrik-johansson fredrik-johansson deleted the sanity branch January 30, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant