Exemplo n.º 1
0
 def crash_in_jit(e):
     tb = not we_are_translated() and sys.exc_info()[2]
     try:
         raise e
     except jitexc.JitException:
         raise     # go through
     except MemoryError:
         raise     # go through
     except StackOverflow:
         raise     # go through
     except Exception, e:
         if not we_are_translated():
             print "~~~ Crash in JIT!"
             print '~~~ %s: %s' % (e.__class__, e)
             if sys.stdout == sys.__stdout__:
                 import pdb; pdb.post_mortem(tb)
             raise e.__class__, e, tb
         fatalerror('~~~ Crash in JIT! %s' % (e,))
Exemplo n.º 2
0
 def crash_in_jit(e):
     tb = not we_are_translated() and sys.exc_info()[2]
     try:
         raise e
     except jitexc.JitException:
         raise     # go through
     except MemoryError:
         raise     # go through
     except StackOverflow:
         raise     # go through
     except Exception, e:
         if not we_are_translated():
             print "~~~ Crash in JIT!"
             print '~~~ %s: %s' % (e.__class__, e)
             if sys.stdout == sys.__stdout__:
                 import pdb; pdb.post_mortem(tb)
             raise e.__class__, e, tb
         fatalerror('~~~ Crash in JIT! %s' % (e,))
Exemplo n.º 3
0
 def portal(codeno, frame):
     print 'ENTER:', codeno, frame.thing.val
     i = 0
     while i < 10:
         driver.can_enter_jit(frame=frame, codeno=codeno, i=i)
         driver.jit_merge_point(frame=frame, codeno=codeno, i=i)
         nextval = frame.thing.val
         if codeno == 0:
             subframe = Frame()
             subframe.thing = Thing(nextval)
             nextval = portal(1, subframe)
         elif codeno == 1:
             if frame.thing.val > 40:
                 change(Thing(13))
                 nextval = 13
         else:
             fatalerror("bad codeno = " + str(codeno))
         frame.thing = Thing(nextval + 1)
         i += 1
     print 'LEAVE:', codeno, frame.thing.val
     return frame.thing.val
Exemplo n.º 4
0
def from_ref(space, ref):
    """
    Finds the interpreter object corresponding to the given reference.  If the
    object is not yet realized (see bytesobject.py), creates it.
    """
    assert is_pyobj(ref)
    if not ref:
        return None
    w_obj = rawrefcount.to_obj(W_Root, ref)
    if w_obj is not None:
        if w_obj is not w_marker_deallocating:
            return w_obj
        type_name = rffi.charp2str(cts.cast('char*', ref.c_ob_type.c_tp_name))
        fatalerror(
            "*** Invalid usage of a dying CPython object ***\n"
            "\n"
            "cpyext, the emulation layer, detected that while it is calling\n"
            "an object's tp_dealloc, the C code calls back a function that\n"
            "tries to recreate the PyPy version of the object.  Usually it\n"
            "means that tp_dealloc calls some general PyXxx() API.  It is\n"
            "a dangerous and potentially buggy thing to do: even in CPython\n"
            "the PyXxx() function could, in theory, cause a reference to the\n"
            "object to be taken and stored somewhere, for an amount of time\n"
            "exceeding tp_dealloc itself.  Afterwards, the object will be\n"
            "freed, making that reference point to garbage.\n"
            ">>> PyPy could contain some workaround to still work if\n"
            "you are lucky, but it is not done so far; better fix the bug in\n"
            "the CPython extension.\n"
            ">>> This object is of type '%s'" % (type_name, ))

    # This reference is not yet a real interpreter object.
    # Realize it.
    ref_type = rffi.cast(PyObject, ref.c_ob_type)
    if ref_type == ref:  # recursion!
        raise InvalidPointerException(str(ref))
    w_type = from_ref(space, ref_type)
    assert isinstance(w_type, W_TypeObject)
    return get_typedescr(w_type.layout.typedef).realize(space, ref)
Exemplo n.º 5
0
def from_ref(space, ref):
    """
    Finds the interpreter object corresponding to the given reference.  If the
    object is not yet realized (see bytesobject.py), creates it.
    """
    assert is_pyobj(ref)
    if not ref:
        return None
    w_obj = rawrefcount.to_obj(W_Root, ref)
    if w_obj is not None:
        if w_obj is not w_marker_deallocating:
            return w_obj
        fatalerror(
            "*** Invalid usage of a dying CPython object ***\n"
            "\n"
            "cpyext, the emulation layer, detected that while it is calling\n"
            "an object's tp_dealloc, the C code calls back a function that\n"
            "tries to recreate the PyPy version of the object.  Usually it\n"
            "means that tp_dealloc calls some general PyXxx() API.  It is\n"
            "a dangerous and potentially buggy thing to do: even in CPython\n"
            "the PyXxx() function could, in theory, cause a reference to the\n"
            "object to be taken and stored somewhere, for an amount of time\n"
            "exceeding tp_dealloc itself.  Afterwards, the object will be\n"
            "freed, making that reference point to garbage.\n"
            ">>> PyPy could contain some workaround to still work if\n"
            "you are lucky, but it is not done so far; better fix the bug in\n"
            "the CPython extension.")

    # This reference is not yet a real interpreter object.
    # Realize it.
    ref_type = rffi.cast(PyObject, ref.c_ob_type)
    if ref_type == ref: # recursion!
        raise InvalidPointerException(str(ref))
    w_type = from_ref(space, ref_type)
    assert isinstance(w_type, W_TypeObject)
    return get_typedescr(w_type.layout.typedef).realize(space, ref)
Exemplo n.º 6
0
def do_assert_not_none(cpu, _, box):
    if not box.getref_base():
        fatalerror("found during JITting: ll_assert_not_none() failed")
Exemplo n.º 7
0
def out_of_memory(errmsg):
    """Signal a fatal out-of-memory error and abort.  For situations where
    it is hard to write and test code that would handle a MemoryError
    exception gracefully.
    """
    fatalerror(errmsg)
Exemplo n.º 8
0
def out_of_memory(errmsg):
    """Signal a fatal out-of-memory error and abort.  For situations where
    it is hard to write and test code that would handle a MemoryError
    exception gracefully.
    """
    fatalerror(errmsg)