New issue 2904: Jit and the copy module causes miscompilation https://bitbucket.org/pypy/pypy/issues/2904/jit-and-the-copy-module-causes
Björn Lindqvist: See the following test code: ``` #!python import copy def eva(board, w): height = len(board) - 1 width = len(board[0]) eb = copy.copy(list(reversed(board[0:height]))) ch = [0]*width for c in range(width): # Works if I add the assert!!! #assert height == 20 h = height-1 while h > 0: if eb[h][c] != 0: break h -= 1 ch[c] = h + 1 return max(ch) board = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [4, 0, 0, 1, 1, 0, 0, 0, 0, 0], [4, 4, 4, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ] for x in range(50): print(eva(list(board), [1.0, 1.0, 5.0, 2.0, 1.0, 1.0, 1.0])) ``` When running it with pypy it correctly prints 3 for about 40 loops. Then the JIT runs and after that it prints 2 instead. Python ofc prints the right answer 3 all the time. pypy3 version 3.5.3 and python3 3.7.0. _______________________________________________ pypy-issue mailing list pypy-issue@python.org https://mail.python.org/mailman/listinfo/pypy-issue