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.
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.
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
</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.
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".
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.
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 ...".