New issue 2528: PyPy follows incorrect execution path. https://bitbucket.org/pypy/pypy/issues/2528/pypy-follows-incorrect-execution-path
jim_r: Under PyPy 5.7.1 (and also PyPy 5.7.0, PyPy 5.6.0) the attached program (pypy-bug.py) aborts after 3.3s. However, if the assertion at line 108 in the code is not commented out the program runs to completion (in 1.36s), and the assertion is not triggered. I believe that the error occurs because the program is following an execution path that should not be possible. The program is a simplified version of the program I wrote to provide a constructive demonstration of the solution to Enigma 1137, see [ [https://enigmaticcode.wordpress.com/2016/12/09/enigma-1137-on-off-on-off/#comment-5256](Link URL) ]. At some point in the recursive solve() routine, execution is falling off the bottom of the function (and returning None). However it should always return a list value. The point of return from the function depends on the length of the list "lights". If it is even, a value is returned at line 105. If it is odd, it is returned at 114, provided a switch was found that operates an odd number of lights. In my comment on the Enigmatic Code site I provide a mathematical proof that shows this is always the case, so it should not be possible to for execution to run off the end of the function. (Which is why I tried adding the assertion at l ine 108, and was surprised to find that this caused the error to go away). I am using PyPy 5.7.0 provided by MacPorts. (But I checked that the program also fails on PyPy 5.7.1 downloaded from pypy.org). % pypy --version Python 2.7.13 (fa3249d55d15b9829e1be69cdf45b5a44cec902d, Mar 27 2017, 13:41:37) [PyPy 5.7.0 with GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] My machine is a 13" MacBook Pro (Late 2011), running OS X 10.12.4. Under standard Pythons on my system (also provided by MacPorts) the program runs to completion much faster than under PyPy (537ms for Python 2.7.13, 547ms for Python 3.6.1). The program does **NOT** abort when the "--jit off" parameter is passed to pypy (and in this case I get an execution time of 1.48s). I have various older downloads of PyPy on my system, and of these the program only fails on pypy-4.0.1 and pypy-5.0.0. The list of versions and execution time is given below: pypy3-2.3.1-osx64 1.53s pypy3-2.1-beta1-osx64 3.50s pypy-5.0.0-osx64 **FAIL** 2.50s pypy-4.0.1-osx64 **FAIL** 4.00s pypy-2.5.1-osx64 1.36s pypy-2.5.0-osx64 1.47s pypy-2.4.0-osx64 1.46s pypy-2.3.1-osx64 1.51s pypy-2.3-osx64 1.48s pypy-2.2.1-osx64 1.46s pypy-2.1 1.08s pypy-2.0.2 1.05s pypy-2.0-beta2 1.09s pypy-2.0-beta1 1.05s pypy-1.9 1.07s pypy-1.8 1.10s pypy-1.7 962ms _______________________________________________ pypy-issue mailing list pypy-issue@python.org https://mail.python.org/mailman/listinfo/pypy-issue