Skip to content
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

overflow_check_* failures in tests #3588

Closed
gsnedders opened this issue May 8, 2020 · 0 comments · Fixed by #3591
Closed

overflow_check_* failures in tests #3588

gsnedders opened this issue May 8, 2020 · 0 comments · Fixed by #3591

Comments

@gsnedders
Copy link
Contributor

gsnedders commented May 8, 2020

Running the tests with CC=-ftrapv shows that #1911 isn't the only overflow-related error and we're thus hitting undefined behaviour in other cases; notably in Overflow.c we often do operations on signed integers regardless of whether or not we're in the overflow case. PR forthcoming.

cython$ CFLAGS=-ftrapv python runtests.py overflow
Python 3.8.2 (default, Apr  8 2020, 14:31:25) 
[GCC 9.3.0]

Running tests against Cython 3.0a4 3bba77a2bf9ed7da4c118fd7887658c597e14cd2
Using Cython language level 2.
Backends: c,cpp

Fatal Python error: Aborted

Thread 0x00007fb5bcdce700 (most recent call first):
  File "runtests.py", line 2267 in time_stamper
  File "/usr/lib/python3.8/threading.py", line 870 in run
  File "/usr/lib/python3.8/threading.py", line 932 in _bootstrap_inner
  File "/usr/lib/python3.8/threading.py", line 890 in _bootstrap

Current thread 0x00007fb5bdda3740 (most recent call first):
  File "<doctest overflow_check_int.test_add_const[1]>", line 1 in <module>
  File "/usr/lib/python3.8/doctest.py", line 1329 in __run
  File "/usr/lib/python3.8/doctest.py", line 1476 in run
  File "/usr/lib/python3.8/doctest.py", line 2191 in runTest
  File "/usr/lib/python3.8/unittest/case.py", line 633 in _callTestMethod
  File "/usr/lib/python3.8/unittest/case.py", line 676 in run
  File "/usr/lib/python3.8/unittest/case.py", line 736 in __call__
  File "/usr/lib/python3.8/unittest/suite.py", line 122 in run
  File "runtests.py", line 1315 in run_test
  File "runtests.py", line 1321 in run_forked_test
  File "runtests.py", line 1316 in run_doctests
  File "runtests.py", line 1304 in run_tests
  File "runtests.py", line 1286 in run
  File "/usr/lib/python3.8/unittest/case.py", line 736 in __call__
  File "/usr/lib/python3.8/unittest/suite.py", line 122 in run
  File "/usr/lib/python3.8/unittest/suite.py", line 84 in __call__
  File "/usr/lib/python3.8/unittest/suite.py", line 122 in run
  File "/usr/lib/python3.8/unittest/suite.py", line 84 in __call__
  File "/usr/lib/python3.8/unittest/suite.py", line 122 in run
  File "/usr/lib/python3.8/unittest/suite.py", line 84 in __call__
  File "/usr/lib/python3.8/unittest/runner.py", line 176 in run
  File "runtests.py", line 2573 in runtests
  File "runtests.py", line 2209 in main
  File "runtests.py", line 2595 in <module>
Aborted (core dumped)
@gsnedders gsnedders changed the title Overflow failures in tests overflow_check_* failures in tests May 8, 2020
gsnedders added a commit to gsnedders/cython that referenced this issue May 8, 2020
Signed overflow is undefined behaviour in C and compilers can and do
optimized on that basis.
gsnedders added a commit to gsnedders/cython that referenced this issue May 8, 2020
Signed overflow is undefined behaviour in C and compilers can and do
optimized on that basis.
@scoder scoder added this to the 3.0 milestone May 18, 2020
scoder pushed a commit that referenced this issue May 18, 2020
* Fix #3588: Make existing overflow code safe

Signed overflow is undefined behaviour in C and compilers can and do optimized on that basis.

* Speed up our overflow impls

Note this is primarily based on performance of compilers which do not
support __builtin_add_overflow (i.e., not Clang >= 3.4 & gcc >= 5),
mostly looking at several gcc 4 releases (used by older, supported,
RHEL releases and Debian 8 "Jessie") and MSVC.

* Use __builtin_XXX_overflow if available

This is much quicker in general, as these all just then read the overflow flag from the status register.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants