[pypy-issue] [issue925] RPython arrays sometimes getting the wrong type?

Laurence Tratt tracker at bugs.pypy.org
Thu Oct 27 22:19:36 CEST 2011

New submission from Laurence Tratt <laurie at tratt.net>:

This patch to the RPython Converge VM was meant to be a simple code tidy-up:


Under --opt=3 and below it works fine. With --opt=jit, the translation throws
up this error:

  [translation:ERROR] Error:
  [translation:ERROR]  Traceback (most recent call last):
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/translator/goal/translate.py", line 308, in main
  [translation:ERROR]     drv.proceed(goals)
  [translation:ERROR]    File "/home/ltratt/tmp/pypy/pypy/translator/driver.py",
line 809, in proceed
  [translation:ERROR]     return self._execute(goals, task_skip =
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/translator/tool/taskengine.py", line 116, in _execute
  [translation:ERROR]     res = self._do(goal, taskcallable, *args, **kwds)
  [translation:ERROR]    File "/home/ltratt/tmp/pypy/pypy/translator/driver.py",
line 286, in _do
  [translation:ERROR]     res = func()
  [translation:ERROR]    File "/home/ltratt/tmp/pypy/pypy/translator/driver.py",
line 397, in task_pyjitpl_lltype
  [translation:ERROR]     backend_name=self.config.translation.jit_backend,
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/metainterp/warmspot.py", line 43, in apply_jit
  [translation:ERROR]     **kwds)
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/metainterp/warmspot.py", line 210, in __init__
  [translation:ERROR]     self.codewriter.make_jitcodes(verbose=verbose)
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/codewriter/codewriter.py", line 72, in make_jitcodes
  [translation:ERROR]     self.transform_graph_to_jitcode(graph, jitcode, verbose)
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/codewriter/codewriter.py", line 41, in
  [translation:ERROR]     transform_graph(graph, self.cpu, self.callcontrol,
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/codewriter/jtransform.py", line 24, in
  [translation:ERROR]     t.transform(graph)
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/codewriter/jtransform.py", line 43, in transform
  [translation:ERROR]     self.optimize_block(block)
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/codewriter/jtransform.py", line 67, in
  [translation:ERROR]     oplist = self.rewrite_operation(op)
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/codewriter/jtransform.py", line 202, in
  [translation:ERROR]     return rewrite(self, op)
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/codewriter/jtransform.py", line 520, in
  [translation:ERROR]     arraydescr = self.cpu.arraydescrof(ARRAY)
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/backend/llsupport/llmodel.py", line 236, in
  [translation:ERROR]     return get_array_descr(self.gc_ll_descr, A)
  [translation:ERROR]    File
"/home/ltratt/tmp/pypy/pypy/jit/backend/llsupport/descr.py", line 254, in
  [translation:ERROR]     assert isinstance(ARRAY, lltype.GcArray)
  [translation:ERROR]  AssertionError

Sticking a print in to see what type ARRAY is gives this:

  Array of * Func ( * GcStruct VM.VM { super, inst_pypy_config, inst_builtins,
inst_cf_stack, inst_mods, inst_spare_ff, inst_st } ) -> Void 

It turns out that only one tiny little part of the patch causes problems.
This patch reverts two lines:


but then ARRAY has what I assume is the correct type:

  GcArray of dictentry { key: * GcStruct rpy_string { hash, chars }, value: *
GcStruct object { typeptr } } 

At the very least, everything executes as I would expect with this type!

What's weird is that executing one of:

    Builtins.new_c_con_func_for_mod(vm, "exit", exit, mod)
    Builtins.new_c_con_func_for_mod(vm, "println", println, mod)

on their own is fine (i.e. comment out either one, and things translate
fine). It's only in conjunction with each other that they throw a problem.

This is all running against PyPy HEAD. I have to be honest, this one has
got me completely stumped.

messages: 3388
nosy: ltratt, pypy-issue
priority: bug
status: unread
title: RPython arrays sometimes getting the wrong type?

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list