pypy6.0 AssertionError if added --objspace-std-withprebuiltint option

Create issue
Issue #2926 resolved
zhang yao created an issue

Hello, We are using pypy6.0 for our project, But when we turn on the withprebuiltin translation-option, there is a certain probability that a crash will occur.

RPython traceback:
  File "rpython_jit_metainterp_10.c", line 43844, in send_bridge_to_backend
  File "rpython_jit_backend_x86_3.c", line 28386, in Assembler386_assemble_bridge
  File "rpython_jit_backend_x86.c", line 5467, in Assembler386__assemble
  File "rpython_jit_backend_x86.c", line 11251, in RegAlloc_walk_operations
  File "rpython_jit_backend_x86.c", line 36521, in RegAlloc_consider_jump
  File "rpython_jit_backend_x86_1.c", line 9786, in remap_frame_layout_mixed
  File "rpython_jit_backend_x86_1.c", line 30440, in remap_frame_layout
  File "rpython_jit_backend_x86_1.c", line 23989, in MachineCodeBlockWrapper_INSN_MOVSD
  File "rpython_jit_backend_x86.c", line 14167, in _missing_binary_insn
Fatal RPython error: AssertionError

Aborted (core dumped)

Then I have tried to summarize a simple piece of code, which is reproducible, running it will definitely crash immediately:

#test-code:

######################################
data = [ 
{"a": 0,  "b": 1,    "c": 2}, 
{"a": 0,  "b": 1.0,  "c": 2}, 
]


def GetTotalScore(score_map):
        totalScore = 0 
        for score in score_map.itervalues():
            totalScore +=  score
        return totalScore

def foo():
    for d in data:
        GetTotalScore(d)

while True:
    foo()

######################################

That's all the code. The gdb backtrace shows that the test-example hands up in the GetTotalScore function which was being called as jited mode.
Will be great to know more possible to inspect.

PS:

1.My test enviroment and tools :
OS : Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 GNU/Linux

C compiler: gcc 4.9.2

2.The versions of pypy I tested:

1)pypy 6.0.0 statble released

2)the official default branch src (hg updated to: changeset: 95388:c8b8ee6787e9, date:Fri Nov 30 16:20:08 2018 +0100)

both of them cause the same crash.

3.My translation script:

python ../../rpython/bin/rpython --opt=jit --verbose --make-jobs=16 targetpypystandalone --objspace-std-withprebuiltint

4.There is no problem without option: --objspace-std-withprebuiltint

We only open this option for testing.

5.Following are similar examples, which are only a little different from the code above, but run well all, no crash occured, these maybe have some reference values for delevlop-team to find the problem. #non-crash-example1:

data = [ 
{"a": 0,  "b": 1,    "c": 2.0}, #"c" value type modified as float
{"a": 0,  "b": 1.0,  "c": 2.0}, #"c" value type modified as float
]
def GetTotalScore(score_map):
        totalScore = 0 
        for score in score_map.itervalues():
            totalScore +=  score
        return totalScore

def foo():
    for d in data:
        GetTotalScore(d)

while True:
    foo()

#non-crash-example2:

data = [ 
{"a": 0,  "b": 1.0, "c": 2.0}, #"b" value type modified as float
{"a": 0,  "b": 1,   "c": 2.0}, #"b" value type modified as int
]
def GetTotalScore(score_map):
        totalScore = 0 
        for score in score_map.itervalues():
            totalScore +=  score
        return totalScore

def foo():
    for d in data:
        GetTotalScore(d)

while True:
    foo()

#non-crash-example3:

[data = [
{"a": 0,  "b": 1.0},  #item count modified
{"a": 0,  "b": 1},    #item count modified
]
def GetTotalScore(score_map):
        totalScore = 0 
        for score in score_map.itervalues():
            totalScore +=  score
        return totalScore

def foo():
    for d in data:
        GetTotalScore(d)

while True:
    foo()

#non-crash-example4:

data = [ 
{"a": 0,  "b": 1.0, "c": 2.0}, 
{"a": 0,  "b": 1,   "c": 2.0}, 
]
def GetTotalScore(score_map):
        totalScore = 0.0  #modify init value type as float
        for score in score_map.itervalues():
            totalScore +=  score
        return totalScore

def foo():
    for d in data:
        GetTotalScore(d)

while True:
    foo()

#non-crash-example5:

data = [ 
{"a": 0,  "b": 1.0,    "c": 2.0}, 
{"a": 0,  "b": 1,  "c": 2.0}, 
]
def GetTotalScore(score_map):
        totalScore = 0 
        for score in score_map.values():# modify walking target as list
            totalScore +=  score
        return totalScore

def foo():
    for d in data:
        GetTotalScore(d)

while True:
    foo()

Think you.

Comments (8)

  1. Alex Kashirin

    Great to know the issue was isolated, just now got my log with the Assert (after a week), that would not be able to explain that case. (if still needed, please let me know) The case found is much more specific than expected to be, if the first value returned in a method is an INT jit assume it to remain and using the prebuilt whereas gets a float.

    For fast solution, I'll compile without the --objspace-std-withprebuiltint

    Thanks

  2. Armin Rigo

    Thanks Alex. Zhang Yao's small crashing example is much better to debug, and it looks like the same problem---an int versus float issue. Of course it usually works, except in a rare case that you both hit recently (after years of nobody reporting the issue).

  3. Log in to comment