-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
gh-96821: Add config option --with-strict-overflow
#96823
Conversation
-fno-strict-overflow
@ericsnowcurrently Please have a look. I think perhaps we should only add the flag when we detect that the compiler supports it? What do you think? |
Yes, please add a compiler flag check. FWIW, the autoconf changes themselves look good. |
Misc/NEWS.d/next/Build/2022-09-14-10-38-15.gh-issue-96821.Zk2a9c.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems okay to me too.
First, though:
How can we verify (now or in the future) that these modules can't use strict overflow or that everything else can?
Let's discuss this over on gh-96821. |
-fno-strict-overflow
-fstrict-overflow
Misc/NEWS.d/next/Build/2022-09-14-10-38-15.gh-issue-96821.Zk2a9c.rst
Outdated
Show resolved
Hide resolved
…9c.rst Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
@AA-Turner Thanks for the suggestions! Much appreciated. |
configure.ac
Outdated
[--with-strict-overflow], | ||
[choose between -fstrict-overflow or -fno-strict-overflow (default is no)]),[], | ||
[with_strict_overflow=no]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to pick on this further. I would like two more changes before merging:
- The help message is too vague. I'd like something a la: if 'yes', add -fstrict-overflow to CFLAGS, else add -fno-strict-overflow to CFLAGS (default is no).
- Please add a
AC_MSG_WARN
ifac_cv_cc_supports_fstrict_overflow=no
and--with-strict-overflow=yes
("--with-strict-overflow=yes specified, but your compiler does not support the -fstrict-overflow flag"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Don't worry about picking on this, I'm just glad you care enough to make the effort!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just ping me when you've made the changes, and I'll get this merged.
Thanks for shepherding this through, @erlend-aasland! |
...and @matthiasgoergens for doing the work, of course. 😄 |
(I'm working my way through some PRs which have been approved and are labeled "awaiting merge", hence my seemingly bolt from the blue comment. Why? Read here.) This work looks to be completed. Can someone merge? |
I'm awaiting final changes. See #96823 (comment) |
@erlend-aasland I was interested in picking this up, so I added the help message change you suggested here #96823 (comment) to the PR I was looking into adding the warn as well, but I'm not familiar with autoconf. The existing PR looks like it's missing something to me... should we be setting |
Great, thanks :)
Yes; if we don't, |
Please pick this up, if you can. Thanks! I don't have as much time as I would like these days. |
Okay, I think this is ready. I'm not familiar with autoconf, so apologies for any issues! |
Thanks, Shantanu! It looks good, AFAICS. As an improvement, we could rewrite the logic to only check for the compiler switch if |
Gentle ping @hauntsaninja @erlend-aasland This came up in discussion and it looks like we're really close to being |
I think this is ready to merge if we need it. Erlend's last comment is a nice to have and I can address it in a follow up PR. |
Nice to see this progressing! |
Thanks Shantanu and Matthias! |
* main: (21 commits) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives in sub interpreters module (python#102472) pythongh-95672: Fix versionadded indentation of get_pagesize in test.rst (pythongh-102455) pythongh-102416: Do not memoize incorrectly loop rules in the parser (python#102467) pythonGH-101362: Optimise PurePath(PurePath(...)) (pythonGH-101667) pythonGH-101362: Check pathlib.Path flavour compatibility at import time (pythonGH-101664) pythonGH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (python#101665) pythongh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (python#102445) pythonGH-102341: Improve the test function for pow (python#102342) Fix unused classes in a typing test (pythonGH-102437) pythongh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (python#102318) pythongh-102356: Add thrashcan macros to filter object dealloc (python#102426) Move around example in to_bytes() to avoid confusion (python#101595) pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (python#102421) pythongh-96821: Add config option `--with-strict-overflow` (python#96823) pythongh-101992: update pstlib module documentation (python#102133) pythongh-63301: Set exit code when tabnanny CLI exits on error (python#7699) pythongh-101863: Fix wrong comments in EUC-KR codec (pythongh-102417) pythongh-102302 Micro-optimize `inspect.Parameter.__hash__` (python#102303) pythongh-102179: Fix `os.dup2` error reporting for negative fds (python#102180) pythongh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (python#101896) ...
* main: (37 commits) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives in sub interpreters module (python#102472) pythongh-95672: Fix versionadded indentation of get_pagesize in test.rst (pythongh-102455) pythongh-102416: Do not memoize incorrectly loop rules in the parser (python#102467) pythonGH-101362: Optimise PurePath(PurePath(...)) (pythonGH-101667) pythonGH-101362: Check pathlib.Path flavour compatibility at import time (pythonGH-101664) pythonGH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (python#101665) pythongh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (python#102445) pythonGH-102341: Improve the test function for pow (python#102342) Fix unused classes in a typing test (pythonGH-102437) pythongh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (python#102318) pythongh-102356: Add thrashcan macros to filter object dealloc (python#102426) Move around example in to_bytes() to avoid confusion (python#101595) pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (python#102421) pythongh-96821: Add config option `--with-strict-overflow` (python#96823) pythongh-101992: update pstlib module documentation (python#102133) pythongh-63301: Set exit code when tabnanny CLI exits on error (python#7699) pythongh-101863: Fix wrong comments in EUC-KR codec (pythongh-102417) pythongh-102302 Micro-optimize `inspect.Parameter.__hash__` (python#102303) pythongh-102179: Fix `os.dup2` error reporting for negative fds (python#102180) pythongh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (python#101896) ...
Please see the issue for details.
This PR marks the modules that need
-fno-strict-overflow
and adds machinery to force-fstrict-overflow
, if the users wants that.As far as is currently known, the three remaining modules that rely on defined integer overflow are fixed by:
_struct
: gh-96735: Fix undefined behaviour in struct unpacking functions #96739audioop
: gh-96821: Fix undefined behaviour inaudioop.c
#96923_ctypes
: gh-96821: Fix undefined behaviour in_ctypes/cfield.c
#96925-fstrict-overflow
#96821