[pypy-dev] Debugging Blocked Block exceptions

Timothy Baldridge tbaldridge at gmail.com
Fri Feb 21 15:45:30 CET 2014


In an interpreter I'm writing I'm often running into Blocked block
exceptions. I've been able to solve several of these errors but the problem
is always figuring out what exactly I've done to cause the error. Most of
the time it seems to come down to some sort of missing assertions that
cause the translator to think that there is no way for an operation to
succeed, but I just can't find it.

For example, I'm currently getting this error:

[translation:ERROR] AnnotatorError:
[translation:ERROR]
[translation:ERROR] Blocked block -- operation cannot succeed
[translation:ERROR]
[translation:ERROR]     v1 = getattr(v0, ('data'))
[translation:ERROR]
[translation:ERROR] In <FunctionGraph of (clojure.vm.array:18)Array.aget at
0x1019d52d0>:
[translation:ERROR] Happened at file
/Users/tim/oss/clojure-vm/clojure/vm/array.py line 20
[translation:ERROR]
[translation:ERROR] ==>         return self.data[idx]
[translation:ERROR]
[translation:ERROR] Known variable annotations:
[translation:ERROR]  v0 = SomeInstance(can_be_None=False,
classdef=clojure.vm.array.Array)


for this class:

from clojure.vm.object import Object, type_ids
from clojure.vm.primitives import nil


class Array(Object):
    type_id = type_ids.next()

    def __init__(self, data, meta = nil):
        self.data = data
        self.meta = meta

    def type(self):
        return self.type_id

    def aclone(self):
        return Array(self.data[:], self.meta)

    def aget(self, idx):
        assert isinstance(idx, int)
        return self.data[idx]

    def aset(self, idx, val):
        assert isinstance(idx, int)
        assert isinstance(val, Object)
        self.data[idx] = val

    def alength(self):
        return len(self.data)


Of course, the error is wrong, and it must be related to some other part of
the code, but I feel like a blind man in the dark trying to find it. Is
there any good way to debug these sorts of errors?

Timothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20140221/a292ee34/attachment.html>


More information about the pypy-dev mailing list