Quantcast

[issue9530] integer undefined behaviors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor

New submission from John Regehr <[hidden email]>:

I ran "make test" for today's Python3k snapshot under a tool which detects math operations that the C language considers to have undefined behavior.  This was on x86 Linux.  The list of undefined behaviors is attached.  Hopefully they are self-explanatory, but please let me know if more details are needed.

----------
files: python-errors.txt
messages: 113079
nosy: regehr
priority: normal
severity: normal
status: open
title: integer undefined behaviors
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file18412/python-errors.txt

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor

Mark Dickinson <[hidden email]> added the comment:

This is good stuff!  Thank you!  I'll look through these.

Is the tool you used publicly available?

----------
assignee:  -> mark.dickinson
nosy: +mark.dickinson

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Changes by Eric Smith <[hidden email]>:


----------
nosy: +eric.smith

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Mark Dickinson <[hidden email]> added the comment:

Here are some fixes for Objects/bytesobject.c and Objects/bytearrayobject.c.  More to come.

----------
keywords: +patch
versions: +Python 3.2 -Python 3.3
Added file: http://bugs.python.org/file18415/issue9530_1.patch

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

John Regehr <[hidden email]> added the comment:

Hi Mark-- Glad it's useful! We plan to release this tool but haven't done so yet, it still has rough edges.  It's LLVM-based and it seems likely they will take our patches.

----------

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Mark Dickinson <[hidden email]> added the comment:

Fixed two more bytearray problems in r83768.

----------

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Mark Dickinson <[hidden email]> added the comment:

Applied issue9530_1.patch in r83936.

----------

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Mark Dickinson <[hidden email]> added the comment:

Status update:  all the reported errors from the Objects/ directory have been fixed in the default branch (many of these were fixed recently as part of making sure that the test-suite runs under Clang's -ftrapv option), or are out of date.  I haven't checked the reports for the extension Modules.

----------
versions: +Python 3.3 -Python 3.2

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Mark Dickinson <[hidden email]> added the comment:

See also issue #1621.

----------

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Mark Dickinson <[hidden email]> added the comment:

The issues reported for the datetime, array, itertools and math modules are also already fixed.  That just leaves the following two of the reported issues outstanding:

</home/regehr/z/python/Modules/_ctypes/cfield.c, (590:5)> : Op: <<=, Reason : Signed Left Shift Error: Right operand is negative or is greater than or equal to the width of the promoted left operand, BINARY OPERATION: left (int32): 0 right (int32): -2

and

</home/regehr/z/python/Modules/testcapi_long.h, (37:47)> : Op: -, Reason : Signed Subtraction Overflow, UNARY OPERATION: left (int32): 0 right (int32): -2147483648

I'm using r63764 as the revision that the line numbers relate to; not sure whether this exactly right, but it seems to be close enough.

----------

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

John Regehr <[hidden email]> added the comment:

This is great.  I'd be happy to re-run the tests sometime, and also we're talking with the LLVM folks about getting our patches into the main LLMM tree.  Basically it'll act as a more powerful -ftrapv, and the error message will be much better than "aborted".

----------

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Roundup Robot <[hidden email]> added the comment:

New changeset 71100ef4f7a2 by Mark Dickinson in branch 'default':
Issue #9530: Fix undefined behaviour due to signed overflow in testcapi_long.h.
http://hg.python.org/cpython/rev/71100ef4f7a2

----------
nosy: +python-dev

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Changes by Jesús Cea Avión <[hidden email]>:


----------
nosy: +jcea

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Mark Dickinson <[hidden email]> added the comment:

> I'd be happy to re-run the tests sometime.

Yes, please!  Alternatively, if there are easy instructions for us to re-run these tests, that would be valuable, too.  Do I understand correctly that you have a publicly available extension to LLVM for this?

> Basically it'll act as a more powerful -ftrapv, and the error message will be much better than "aborted".

Indeed---there were a number of places where tracking down the exact cause of the error using a combination of -ftrapv and gdb was painful. :-)

I'm aware of two current issues: one in Python/formatter_unicode.c, and one in Modules/timemodule.c.  I'll try to fix these shortly.

----------

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

John Regehr <[hidden email]> added the comment:

Hi Mark, yes you can run the overflow checker but "easy instructions" depends on whether you feel like building your own LLVM.  It is not at all difficult, but it's certainly not as easy as "apt-get install ...".

Patch and instructions are here:

  http://embed.cs.utah.edu/ioc/

If/when we get this into LLVM (the earliest possible release containing IOC will be 3.1), I'll let you know.  Thanks again.

----------

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%40nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Mark Dickinson <[hidden email]> added the comment:

See also issue #13496.

----------

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%2B1322467933539-512619%40n6.nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Changes by Mark Dickinson <[hidden email]>:


----------
dependencies: +Integer overflow in classic string formatting

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%2B1322467933539-512619%40n6.nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

John Regehr <[hidden email]> added the comment:

Hi folks,

I realize it was a long time ago that I reported this issue!  Since then our tool has been made available:

  http://embed.cs.utah.edu/ioc/

In particular, that web page contains a pre-compiled version of the tool for recent Ubuntu on x86-64, that should be pretty easy to use.

Alternatively, I can re-run the Python test suite on a Python compiled using our tool.  Let me know if this would be helpful.

----------

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%2B1322467933539-512619%40n6.nabble.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[issue9530] integer undefined behaviors

STINNER Victor
In reply to this post by STINNER Victor

Changes by Stefan Krah <[hidden email]>:


----------
nosy: +skrah

_______________________________________
Python tracker <[hidden email]>
<http://bugs.python.org/issue9530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/lists%2B1322467933539-512619%40n6.nabble.com

Loading...