[issue20932] Undefined behavior flagged by Clang 3.4 (Python 3.5 from hg)

2016-07-20 Thread Martin Panter

Martin Panter added the comment:

Serhiy’s patch does fix about half the errors (1 whole screenful reduces to a 
bit over 1/2 a screenful). I do find it a bit ugly though (four casts in the 
one term of a macro!).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20932] Undefined behavior flagged by Clang 3.4 (Python 3.5 from hg)

2016-07-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20932] Undefined behavior flagged by Clang 3.4 (Python 3.5 from hg)

2014-03-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Please try this patch. Perhaps it fixes audioop issues.

--
keywords: +patch
nosy: +serhiy.storchaka
Added file: http://bugs.python.org/file34493/audioop_signed_left_shift.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20932
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20932] Undefined behavior flagged by Clang 3.4 (Python 3.5 from hg)

2014-03-18 Thread Benjamin Peterson

Benjamin Peterson added the comment:

No, it still gives

/home/benjamin/dev/python/3.4/Modules/audioop.c:1811:9: runtime error: left 
shift of negative value -22
/home/benjamin/dev/python/3.4/Modules/audioop.c:1811:9: runtime error: left 
shift of negative value -22
/home/benjamin/dev/python/3.4/Modules/audioop.c:1811:9: runtime error: left 
shift of negative value -22
/home/benjamin/dev/python/3.4/Modules/audioop.c:1811:9: runtime error: left 
shift of negative value -22
/home/benjamin/dev/python/3.4/Modules/audioop.c:1811:9: runtime error: left 
shift of negative value -22
/home/benjamin/dev/python/3.4/Modules/audioop.c:1811:9: runtime error: left 
shift of negative value -22
/home/benjamin/dev/python/3.4/Modules/audioop.c:1587:39: runtime error: left 
shift of negative value -5504
/home/benjamin/dev/python/3.4/Modules/audioop.c:1546:19: runtime error: left 
shift of negative value -5504
/home/benjamin/dev/python/3.4/Modules/audioop.c:1546:19: runtime error: left 
shift of negative value -1409024
/home/benjamin/dev/python/3.4/Modules/audioop.c:1639:19: runtime error: left 
shift of negative value -69
/home/benjamin/dev/python/3.4/Modules/audioop.c:1639:19: runtime error: left 
shift of negative value -17767
/home/benjamin/dev/python/3.4/Modules/audioop.c:1639:19: runtime error: left 
shift of negative value -4548489
/home/benjamin/dev/python/3.4/Modules/audioop.c:1546:19: runtime error: left 
shift of negative value -69
/home/benjamin/dev/python/3.4/Modules/audioop.c:1244:19: runtime error: left 
shift of negative value -69
/home/benjamin/dev/python/3.4/Modules/audioop.c:1244:19: runtime error: left 
shift of negative value -17767
/home/benjamin/dev/python/3.4/Modules/audioop.c:1244:19: runtime error: left 
shift of negative value -4548489
/home/benjamin/dev/python/3.4/Modules/audioop.c:1473:19: runtime error: left 
shift of negative value -69
/home/benjamin/dev/python/3.4/Modules/audioop.c:1473:19: runtime error: left 
shift of negative value -17767
/home/benjamin/dev/python/3.4/Modules/audioop.c:1473:19: runtime error: left 
shift of negative value -4548489
/home/benjamin/dev/python/3.4/Modules/audioop.c:1418:31: runtime error: left 
shift of negative value -69
/home/benjamin/dev/python/3.4/Modules/audioop.c:1418:31: runtime error: left 
shift of negative value -17767
/home/benjamin/dev/python/3.4/Modules/audioop.c:1418:31: runtime error: left 
shift of negative value -4548489
/home/benjamin/dev/python/3.4/Modules/audioop.c:1513:43: runtime error: left 
shift of negative value -32124

You, too, can build with the undefined behavior sanitizer using the helpful 
instructions at http://docs.python.org/devguide/clang.html

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20932
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20932] Undefined behavior flagged by Clang 3.4 (Python 3.5 from hg)

2014-03-14 Thread Jeffrey Walton

New submission from Jeffrey Walton:

Checked out Python-3.5 from mercurial. Compiled with Clang 3.4, added 
-fsanitzie=undefined to CFLAGS. Ran 'make' and 'make check'. A few issues 
during `make`:

Objects/longobject.c:40:42: runtime error: index -3 out of bounds for type 
'PyLongObject [262]'
Objects/listobject.c:2046:22: runtime error: index 623 out of bounds for type 
'PyObject *[256]'
Objects/longobject.c:40:42: runtime error: index -3 out of bounds for type 
'PyLongObject [262]'

Similar issues with `make test`, with the addition of some mis-aligned 
pointers. A digest is below, and the tagCDataObject alignment issue dominates 
the issues. The tests ended early due to a segfault.

$ make test
...
[ 19/389/1] test_struct
Objects/longobject.c:40:42: runtime error: index -3 out of bounds for type 
'PyLongObject [262]'
/home/jwalton/Desktop/cpython-checkout/Objects/floatobject.c:2028: runtime 
error: value 3.40282e+38 is outside the range of representable values of type 
'float'
/home/jwalton/Desktop/cpython-checkout/Modules/_struct.c:792:15: runtime error: 
left shift of 72057594037927935 by 8 places cannot be represented in type 'long 
long'
...
[ 43/389/2] test_cmd_line
Objects/longobject.c:40:42: runtime error: index -3 out of bounds for type 
'PyLongObject [262]'
Objects/longobject.c:40:42: runtime error: index -3 out of bounds for type 
'PyLongObject [262]'
Objects/longobject.c:40:42: runtime error: index -3 out of bounds for type 
'PyLongObject [262]'
/home/jwalton/Desktop/cpython-checkout/Modules/_ctypes/_ctypes.c:2890:10: 
runtime error: member access within misaligned address 0x2b54033f1cc8 for type 
'CDataObject' (aka 'struct tagCDataObject'), which requires 16 byte alignment
0x2b54033f1cc8: note: pointer points here
 ff ff ff ff  01 00 00 00 00 00 00 00  68 06 43 03 00 00 00 00  00 00 00 00 00 
00 00 00  00 00 00 00
  ^ 
test test_cmd_line failed -- multiple errors occurred; run in verbose mode for 
details
...
[ 45/389/2] test_datetime
Objects/longobject.c:40:42: runtime error: index -3 out of bounds for type 
'PyLongObject [262]'
/home/jwalton/Desktop/cpython-checkout/Python/pytime.c:218: runtime error: 
value -1e+200 is outside the range of representable values of type 'long'
/home/jwalton/Desktop/cpython-checkout/Python/pytime.c:218: runtime error: 
value 1e+200 is outside the range of representable values of type 'long'
...
test test_traceback failed -- Traceback (most recent call last):
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/test_traceback.py, 
line 155, in test_encoded_file
do_test(, foo, ascii, 3)
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/test_traceback.py, 
line 132, in do_test
stdout = stdout.decode(output_encoding).splitlines()
LookupError: unknown encoding: Objects/longobject.c:40:42: runtime error: index 
-3 out of bounds for type 'PyLongObject [262]'
...
[130/389/5] test_capi
Objects/longobject.c:40:42: runtime error: index -3 out of bounds for type 
'PyLongObject [262]'
Fatal Python error: Segmentation fault

Current thread 0x2b6eaf8c7b20 (most recent call first):
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/test_capi.py, line 466 
in test__testcapi
  File /home/jwalton/Desktop/cpython-checkout/Lib/unittest/case.py, line 574 
in run
  File /home/jwalton/Desktop/cpython-checkout/Lib/unittest/case.py, line 622 
in __call__
  File /home/jwalton/Desktop/cpython-checkout/Lib/unittest/suite.py, line 125 
in run
  File /home/jwalton/Desktop/cpython-checkout/Lib/unittest/suite.py, line 87 
in __call__
  File /home/jwalton/Desktop/cpython-checkout/Lib/unittest/suite.py, line 125 
in run
  File /home/jwalton/Desktop/cpython-checkout/Lib/unittest/suite.py, line 87 
in __call__
  File /home/jwalton/Desktop/cpython-checkout/Lib/unittest/suite.py, line 125 
in run
  File /home/jwalton/Desktop/cpython-checkout/Lib/unittest/suite.py, line 87 
in __call__
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/support/__init__.py, 
line 1584 in run
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/support/__init__.py, 
line 1685 in _run_suite
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/support/__init__.py, 
line 1719 in run_unittest
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/regrtest.py, line 1277 
in lambda
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/regrtest.py, line 1278 
in runtest_inner
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/regrtest.py, line 978 
in runtest
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/regrtest.py, line 532 
in main
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/regrtest.py, line 1562 
in main_in_temp_cwd
  File /home/jwalton/Desktop/cpython-checkout/Lib/test/regrtest.py, line 1587 
in module
  File /home/jwalton/Desktop/cpython-checkout/Lib/runpy.py, line 86 in 
_run_code
  File /home/jwalton/Desktop/cpython-checkout/Lib/runpy.py, line 171 in 
_run_module_as_main
Traceback (most recent call last):
  File 

[issue20932] Undefined behavior flagged by Clang 3.4 (Python 3.5 from hg)

2014-03-14 Thread Jeffrey Walton

Changes by Jeffrey Walton noloa...@gmail.com:


Added file: http://bugs.python.org/file34429/python-3.5-make-test.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20932
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20932] Undefined behavior flagged by Clang 3.4 (Python 3.5 from hg)

2014-03-14 Thread Benjamin Peterson

Benjamin Peterson added the comment:

This is just the same as #20929, I believe?

--
nosy: +benjamin.peterson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20932
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20932] Undefined behavior flagged by Clang 3.4 (Python 3.5 from hg)

2014-03-14 Thread Jeffrey Walton

Jeffrey Walton added the comment:

Pulled the latest after BP cleared some more runtime errors:

  $ hg summary
  parent: 89662:7ce22d0899e4 tip
   merge 3.3
  branch: default
  commit: 2 modified
  update: (current)

Misaligned accesses dominate with over 11K:

  $ cat python-3.5-make-test.txt | grep misaligned | wc -l
  11320

*

$ make test
...

[ 21/389] test_sort
Objects/listobject.c:1973:30: runtime error: index 257 out of bounds for type 
'PyObject *[256]'
...
[ 31/389] test_xml_etree
/home/jwalton/Desktop/cpython-checkout/Modules/expat/xmltok.c:1396:11: runtime 
error: left shift of 1 by 31 places cannot be represented in type 'int'
/home/jwalton/Desktop/cpython-checkout/Modules/expat/xmltok.c:1398:16: runtime 
error: left shift of 1 by 31 places cannot be represented in type 'int'
...
[ 33/389] test_aifc
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1587:39: runtime 
error: left shift of negative value -24
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1546:19: runtime 
error: left shift of negative value -24
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1513:43: runtime 
error: left shift of negative value -24
...
[ 61/389] test_httplib
/home/jwalton/Desktop/cpython-checkout/Lib/socket.py:444: ResourceWarning: 
unclosed ssl.SSLSocket fd=4, family=AddressFamily.AF_INET, type=2049, proto=6, 
laddr=('172.16.1.26', 51321), raddr=('82.94.164.164', 443)
  self._sock = None
...
[ 99/389] test_audioop
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1060:20: runtime 
error: left shift of negative value -70
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1061:20: runtime 
error: left shift of negative value -70
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1811:9: runtime error: 
left shift of negative value -22
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1811:9: runtime error: 
left shift of negative value -22
...
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:422:11: runtime error: 
left shift of negative value -1
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1639:19: runtime 
error: left shift of negative value -69
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1639:19: runtime 
error: left shift of negative value -17767
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1639:19: runtime 
error: left shift of negative value -70
/home/jwalton/Desktop/cpython-checkout/Modules/audioop.c:1639:19: runtime 
error: left shift of negative value -4548489
...
[109/389] test_unicode
/home/jwalton/Desktop/cpython-checkout/Modules/_ctypes/_ctypes.c:2890:10: 
runtime error: member access within misaligned address 0x2ac5068c24f8 for type 
'CDataObject' (aka 'struct tagCDataObject'), which requires 16 byte alignment
0x2ac5068c24f8: note: pointer points here
 ff ff ff ff  01 00 00 00 00 00 00 00  78 e4 af 02 00 00 00 00  00 00 00 00 00 
00 00 00  00 00 00 00
  ^ 
/home/jwalton/Desktop/cpython-checkout/Modules/_ctypes/_ctypes.c:2891:10: 
runtime error: member access within misaligned address 0x2ac5068c24f8 for type 
'CDataObject' (aka 'struct tagCDataObject'), which requires 16 byte alignment
0x2ac5068c24f8: note: pointer points here
 ff ff ff ff  01 00 00 00 00 00 00 00  78 e4 af 02 00 00 00 00  00 00 00 00 00 
00 00 00  00 00 00 00
  ^ 
...
/home/jwalton/Desktop/cpython-checkout/Modules/_ctypes/_ctypes.c:3862:5: 
runtime error: member access within misaligned address 0x2ae9f1252e58 for type 
'PyCFuncPtrObject', which requires 16 byte alignment
0x2ae9f1252e58: note: pointer points here
 00 00 00 00  01 00 00 00 00 00 00 00  58 0c 8e 02 00 00 00 00  a8 2e 25 f1 e9 
2a 00 00  01 00 00 00
  ^ 
/home/jwalton/Desktop/cpython-checkout/Modules/_ctypes/_ctypes.c:3863:5: 
runtime error: member access within misaligned address 0x2ae9f1252e58 for type 
'PyCFuncPtrObject', which requires 16 byte alignment
0x2ae9f1252e58: note: pointer points here
 00 00 00 00  01 00 00 00 00 00 00 00  58 0c 8e 02 00 00 00 00  a8 2e 25 f1 e9 
2a 00 00  01 00 00 00
  ^ 
...
2 tests failed:
test_faulthandler test_venv
2 tests altered the execution environment:
test___all__ test_warnings
25 tests skipped:
test_bz2 test_crypt test_curses test_dbm_gnu test_dbm_ndbm
test_devpoll test_gdb test_gzip test_idle test_kqueue test_lzma
test_msilib test_nis test_ossaudiodev test_readline test_sqlite
test_startfile test_tcl test_tk test_ttk_guionly test_ttk_textonly
test_winreg test_winsound test_zipfile64 test_zlib

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20932
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20932] Undefined behavior flagged by Clang 3.4 (Python 3.5 from hg)

2014-03-14 Thread Jeffrey Walton

Jeffrey Walton added the comment:

 This is just the same as #20929, I believe?

I think most of the issues in the 20929 report (Python 3.4-RC3) are present in 
this report. But under this report, I can re-test as you check in the fixes. 
(Python 3.4-RC3 is fixed in time from my perspective).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20932
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20932] Undefined behavior flagged by Clang 3.4 (Python 3.5 from hg)

2014-03-14 Thread Jeffrey Walton

Jeffrey Walton added the comment:

Here's another one I missed. The first is a problem due to silent truncation 
when casting from the double 3.40282e+38 to a float (or Clang is wrong).

[ 10/389] test_struct
/home/jwalton/Desktop/cpython-checkout/Objects/floatobject.c:2028: runtime 
error: value 3.40282e+38 is outside the range of representable values of type 
'float'
/home/jwalton/Desktop/cpython-checkout/Modules/_struct.c:792:15: runtime error: 
left shift of 72057594037927935 by 8 places cannot be represented in type 'long 
long'

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20932
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com