classification
Title: Undefined behavior flagged by Clang 3.4 (Python 3.4-RC3)
Type: behavior Stage:
Components: Build Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Jeffrey.Walton, benjamin.peterson, python-dev
Priority: normal Keywords:

Created on 2014-03-15 00:21 by Jeffrey.Walton, last changed 2014-03-15 04:38 by benjamin.peterson. This issue is now closed.

Files
File name Uploaded Description Edit
python-3-4-make.txt Jeffrey.Walton, 2014-03-15 00:21 Results of 'make' with Clang's undefined behavior sanitizer.
python-3-4-make-test.txt Jeffrey.Walton, 2014-03-15 00:39 Results of 'make test' with Clang's undefined behavior sanitizer.
Messages (14)
msg213604 - (view) Author: Jeffrey Walton (Jeffrey.Walton) * Date: 2014-03-15 00:21
Downloaded Python-3.4.0rc3. Compiled with Clang 3.4, added -fsanitzie=undefined to CFLAGS. Ran 'make' and 'make check'.

Lots of issues, many are duplicates (see below). One or more of these issues might be the reason for `-fwrapv`.

This fellow from objimpl.h seems to be the source of many of the issues:

    #define _Py_AS_GC(o) ((PyGC_Head *)(o)-1)

*****

Modules/gcmodule.c:1718:5: runtime error: left shift of negative value -2
Objects/tupleobject.c:120:5: runtime error: left shift of negative value -3
Objects/typeobject.c:905:9: runtime error: left shift of negative value -3
Objects/dictobject.c:818:5: runtime error: left shift of negative value -3
Objects/methodobject.c:45:5: runtime error: left shift of negative value -3
Objects/listobject.c:178:5: runtime error: left shift of negative value -3
Modules/gcmodule.c:1703:9: runtime error: left shift of negative value -2
Modules/gcmodule.c:1693:5: runtime error: left shift of negative value -3
Objects/descrobject.c:9:5: runtime error: left shift of negative value -2
Modules/gcmodule.c:484:13: runtime error: left shift of negative value -3
Objects/tupleobject.c:195:5: runtime error: left shift of negative value -2
Modules/gcmodule.c:503:13: runtime error: left shift of negative value -4
Objects/exceptions.c:2205:5: runtime error: left shift of negative value -2
Objects/longobject.c:40:42: runtime error: index -3 out of bounds for type 'PyLongObject [262]'
Objects/frameobject.c:736:5: runtime error: left shift of negative value -3
Objects/funcobject.c:64:5: runtime error: left shift of negative value -3
Objects/methodobject.c:149:5: runtime error: left shift of negative value -2
Objects/funcobject.c:552:5: runtime error: left shift of negative value -2
Objects/descrobject.c:1364:5: runtime error: left shift of negative value -2
Objects/cellobject.c:16:5: runtime error: left shift of negative value -3
Objects/listobject.c:2744:5: runtime error: left shift of negative value -3
Objects/listobject.c:2751:5: runtime error: left shift of negative value -2
Objects/dictobject.c:3232:5: runtime error: left shift of negative value -3
Objects/dictobject.c:2826:5: runtime error: left shift of negative value -3
Objects/exceptions.c:89:5: runtime error: left shift of negative value -2
Objects/classobject.c:68:5: runtime error: left shift of negative value -3
Objects/classobject.c:193:5: runtime error: left shift of negative value -2
Objects/tupleobject.c:1079:5: runtime error: left shift of negative value -3
Objects/genobject.c:526:5: runtime error: left shift of negative value -3
Objects/tupleobject.c:948:5: runtime error: left shift of negative value -2
Objects/genobject.c:48:5: runtime error: left shift of negative value -2
Objects/genobject.c:53:5: runtime error: left shift of negative value -3
Objects/genobject.c:58:5: runtime error: left shift of negative value -2
Objects/cellobject.c:49:5: runtime error: left shift of negative value -2
Objects/typeobject.c:1170:9: runtime error: left shift of negative value -3
Objects/exceptions.c:662:5: runtime error: left shift of negative value -2
Objects/exceptions.c:1010:5: runtime error: left shift of negative value -2
Objects/exceptions.c:513:5: runtime error: left shift of negative value -2
./Modules/_io/fileio.c:479:5: runtime error: left shift of negative value -2
Objects/setobject.c:944:5: runtime error: left shift of negative value -3
Objects/unicodeobject.c:15267:5: runtime error: left shift of negative value -3
Objects/unicodeobject.c:15128:5: runtime error: left shift of negative value -2
Objects/typeobject.c:6720:5: runtime error: left shift of negative value -2
Objects/bytesobject.c:3006:5: runtime error: left shift of negative value -3
Objects/bytesobject.c:2869:5: runtime error: left shift of negative value -2
Objects/bytearrayobject.c:3094:5: runtime error: left shift of negative value -3
Objects/bytearrayobject.c:2959:5: runtime error: left shift of negative value -2
Objects/descrobject.c:1001:9: runtime error: left shift of negative value -3
Objects/descrobject.c:873:5: runtime error: left shift of negative value -2
Modules/gcmodule.c:861:13: runtime error: left shift of negative value -3
Objects/typeobject.c:2865:5: runtime error: left shift of negative value -2
Objects/dictobject.c:2643:9: runtime error: left shift of negative value -2
Objects/descrobject.c:943:5: runtime error: left shift of negative value -3
Objects/iterobject.c:26:5: runtime error: left shift of negative value -3
Objects/iterobject.c:33:5: runtime error: left shift of negative value -2
Objects/memoryobject.c:74:5: runtime error: left shift of negative value -3
Objects/memoryobject.c:639:5: runtime error: left shift of negative value -3
Objects/memoryobject.c:1060:5: runtime error: left shift of negative value -2
Objects/memoryobject.c:108:5: runtime error: left shift of negative value -2
./Modules/_io/bufferedio.c:402:5: runtime error: left shift of negative value -2
./Modules/_io/textio.c:1156:5: runtime error: left shift of negative value -2
Objects/descrobject.c:1262:9: runtime error: left shift of negative value -3
Objects/listobject.c:2046:22: runtime error: index 623 out of bounds for type 'PyObject *[256]'
Objects/dictobject.c:756:5: runtime error: left shift of negative value -2
Objects/funcobject.c:907:5: runtime error: left shift of negative value -2
Objects/funcobject.c:726:5: runtime error: left shift of negative value -2
Modules/gcmodule.c:1718:5: runtime error: left shift of negative value -2
Objects/tupleobject.c:120:5: runtime error: left shift of negative value -3
Objects/typeobject.c:905:9: runtime error: left shift of negative value -3
Objects/dictobject.c:818:5: runtime error: left shift of negative value -3
Objects/methodobject.c:45:5: runtime error: left shift of negative value -3
Objects/listobject.c:178:5: runtime error: left shift of negative value -3
Modules/gcmodule.c:1703:9: runtime error: left shift of negative value -2
Modules/gcmodule.c:1693:5: runtime error: left shift of negative value -3
Objects/descrobject.c:9:5: runtime error: left shift of negative value -2
Modules/gcmodule.c:484:13: runtime error: left shift of negative value -3
Objects/tupleobject.c:195:5: runtime error: left shift of negative value -2
Modules/gcmodule.c:503:13: runtime error: left shift of negative value -4
Objects/exceptions.c:2205:5: runtime error: left shift of negative value -2
Objects/longobject.c:40:42: runtime error: index -3 out of bounds for type 'PyLongObject [262]'
Objects/frameobject.c:736:5: runtime error: left shift of negative value -3
Objects/funcobject.c:64:5: runtime error: left shift of negative value -3
Objects/methodobject.c:149:5: runtime error: left shift of negative value -2
Objects/funcobject.c:552:5: runtime error: left shift of negative value -2
Objects/descrobject.c:1364:5: runtime error: left shift of negative value -2
Objects/cellobject.c:16:5: runtime error: left shift of negative value -3
Objects/listobject.c:2744:5: runtime error: left shift of negative value -3
Objects/listobject.c:2751:5: runtime error: left shift of negative value -2
Objects/dictobject.c:3232:5: runtime error: left shift of negative value -3
Objects/dictobject.c:2826:5: runtime error: left shift of negative value -3
Objects/exceptions.c:89:5: runtime error: left shift of negative value -2
Objects/classobject.c:68:5: runtime error: left shift of negative value -3
Objects/classobject.c:193:5: runtime error: left shift of negative value -2
Objects/tupleobject.c:1079:5: runtime error: left shift of negative value -3
Objects/genobject.c:526:5: runtime error: left shift of negative value -3
Objects/tupleobject.c:948:5: runtime error: left shift of negative value -2
Objects/genobject.c:48:5: runtime error: left shift of negative value -2
Objects/genobject.c:53:5: runtime error: left shift of negative value -3
Objects/genobject.c:58:5: runtime error: left shift of negative value -2
Objects/cellobject.c:49:5: runtime error: left shift of negative value -2
Objects/typeobject.c:1170:9: runtime error: left shift of negative value -3
Objects/exceptions.c:662:5: runtime error: left shift of negative value -2
Objects/exceptions.c:1010:5: runtime error: left shift of negative value -2
Objects/exceptions.c:513:5: runtime error: left shift of negative value -2
./Modules/_io/fileio.c:479:5: runtime error: left shift of negative value -2
Objects/unicodeobject.c:15267:5: runtime error: left shift of negative value -3
Objects/unicodeobject.c:15128:5: runtime error: left shift of negative value -2
Objects/typeobject.c:6720:5: runtime error: left shift of negative value -2
Objects/setobject.c:944:5: runtime error: left shift of negative value -3
Objects/bytesobject.c:3006:5: runtime error: left shift of negative value -3
Objects/bytesobject.c:2869:5: runtime error: left shift of negative value -2
Objects/bytearrayobject.c:3094:5: runtime error: left shift of negative value -3
Objects/bytearrayobject.c:2959:5: runtime error: left shift of negative value -2
Objects/descrobject.c:1001:9: runtime error: left shift of negative value -3
Objects/descrobject.c:873:5: runtime error: left shift of negative value -2
Modules/gcmodule.c:861:13: runtime error: left shift of negative value -3
Objects/typeobject.c:2865:5: runtime error: left shift of negative value -2
Objects/iterobject.c:26:5: runtime error: left shift of negative value -3
Objects/iterobject.c:33:5: runtime error: left shift of negative value -2
Objects/dictobject.c:2643:9: runtime error: left shift of negative value -2
Objects/descrobject.c:1262:9: runtime error: left shift of negative value -3
Objects/memoryobject.c:74:5: runtime error: left shift of negative value -3
Objects/memoryobject.c:639:5: runtime error: left shift of negative value -3
running build
Objects/memoryobject.c:1060:5: runtime error: left shift of negative value -2
Objects/memoryobject.c:108:5: runtime error: left shift of negative value -2
running build_ext
./Modules/_io/bufferedio.c:402:5: runtime error: left shift of negative value -2
./Modules/_io/textio.c:1156:5: runtime error: left shift of negative value -2
INFO: Can't locate Tcl/Tk libs and/or headers
Objects/tupleobject.c:878:9: runtime error: left shift of negative value -2
Objects/tupleobject.c:896:5: runtime error: left shift of negative value -3
msg213607 - (view) Author: Roundup Robot (python-dev) Date: 2014-03-15 01:15
New changeset e68f156ea0e6 by Benjamin Peterson in branch 'default':
cast negative numbers to size_t before shifting them (#20929)
http://hg.python.org/cpython/rev/e68f156ea0e6
msg213608 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-03-15 01:16
Thanks for the report. Could you check if the current "default" branch of mercurial fixes the problems?
msg213616 - (view) Author: Jeffrey Walton (Jeffrey.Walton) * Date: 2014-03-15 01:58
> Could you check if the current "default" branch of mercurial fixes the problems?

Checkout is complete. Working through a build now.

Could you look at http://bugs.python.org/issue20930 and advise on the best way to proceed?
msg213618 - (view) Author: Jeffrey Walton (Jeffrey.Walton) * Date: 2014-03-15 02:08
The big list of issues earlier has been parred down to the following after `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]'

`make test` still needs to be run.

I'm going to open another bug report since this is a different branch. Is that OK?
msg213619 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-03-15 02:10
What branch are you building now?
msg213621 - (view) Author: Jeffrey Walton (Jeffrey.Walton) * Date: 2014-03-15 02:27
> What branch are you building now?

Python 3.5 from `hg clone http://hg.python.org/cpython`.
msg213622 - (view) Author: Jeffrey Walton (Jeffrey.Walton) * Date: 2014-03-15 02:28
Updated title to reflect Python 3.4-RC3.
msg213623 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-03-15 02:28
Well, that's 3.4.1 atm.
msg213624 - (view) Author: Jeffrey Walton (Jeffrey.Walton) * Date: 2014-03-15 02:31
> Well, that's 3.4.1 atm.

My bad. I managed to download a file named Python-3.4.0rc3.tgz this morning (the tarball is still in my downloads). I'm not sure from where since http://www.python.org/download/ does not have it....
msg213626 - (view) Author: Jeffrey Walton (Jeffrey.Walton) * Date: 2014-03-15 02:39
Also see http://bugs.python.org/issue20932.
msg213627 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-03-15 02:56
Okay, I think I fixed those bugs too on default.
msg213636 - (view) Author: Jeffrey Walton (Jeffrey.Walton) * Date: 2014-03-15 04:37
On Fri, Mar 14, 2014 at 10:28 PM, Benjamin Peterson
<report@bugs.python.org> wrote:
>
> Benjamin Peterson added the comment:
>
> Well, that's 3.4.1 atm.
>
Here's why I got that stale version:
https://www.google.com/search?q=download+python+3.4. The first hit is
RC3.
msg213637 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-03-15 04:38
That's indeed the latest release, but the default branch will become 3.4.1.
History
Date User Action Args
2014-03-17 14:00:43zach.warelinkissue20958 superseder
2014-03-15 04:38:17benjamin.petersonsetmessages: + msg213637
2014-03-15 04:37:14Jeffrey.Waltonsetmessages: + msg213636
2014-03-15 03:20:21benjamin.petersonsetstatus: open -> closed
resolution: fixed
2014-03-15 02:56:21benjamin.petersonsetmessages: + msg213627
2014-03-15 02:39:44Jeffrey.Waltonsetmessages: + msg213626
2014-03-15 02:31:10Jeffrey.Waltonsetmessages: + msg213624
2014-03-15 02:28:30benjamin.petersonsetmessages: + msg213623
2014-03-15 02:28:06Jeffrey.Waltonsetmessages: + msg213622
title: Undefined behavior flagged by Clang 3.4 -> Undefined behavior flagged by Clang 3.4 (Python 3.4-RC3)
2014-03-15 02:27:20Jeffrey.Waltonsetmessages: + msg213621
2014-03-15 02:10:46benjamin.petersonsetmessages: + msg213619
2014-03-15 02:08:44Jeffrey.Waltonsetmessages: + msg213618
2014-03-15 01:58:14Jeffrey.Waltonsetmessages: + msg213616
2014-03-15 01:16:07benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg213608
2014-03-15 01:15:43python-devsetnosy: + python-dev
messages: + msg213607
2014-03-15 00:39:37Jeffrey.Waltonsetfiles: + python-3-4-make-test.txt
2014-03-15 00:21:50Jeffrey.Waltoncreate