VirtualBox

Changeset 102380 in vbox for trunk/src


Ignore:
Timestamp:
Nov 29, 2023 1:45:05 PM (14 months ago)
Author:
vboxsync
Message:

libs/xpcom/python: Attempt at fixing python crashes on darwin.arm64 when using the limited API, the inherited tp_is_gc() method is crashing because it works on a different object type so we define our own, also limit comparison for different object types, bugref:10544

Location:
trunk/src/libs/xpcom18a4/python/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/src/PyIID.cpp

    r90632 r102380  
    237237                { Py_tp_str,            (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_str },
    238238                { Py_tp_richcompare,    (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_richcompare },
     239                { Py_tp_is_gc,          (void *)(uintptr_t)&Py_nsIID::PyTypeMethod_is_gc },
    239240                { 0, NULL } /* terminator */
    240241        };
     
    320321Py_nsIID::PyTypeMethod_richcompare(PyObject *self, PyObject *other, int op)
    321322{
     323    if (self->ob_type != other->ob_type) /* Different types can't be compared. */
     324    {
     325        if (op == Py_EQ)
     326            Py_RETURN_FALSE;
     327        else if (op == Py_NE)
     328            Py_RETURN_TRUE;
     329
     330       /* different are not comparable. */
     331       PyErr_SetString(PyExc_TypeError, "Comparison between different object types is not defined");
     332       return NULL;
     333    }
     334
    322335    PyObject *result = NULL;
    323336        Py_nsIID *s_iid = (Py_nsIID *)self;
     
    409422        delete (Py_nsIID *)ob;
    410423}
     424
     425#ifdef Py_LIMITED_API
     426/* static */ int
     427Py_nsIID::PyTypeMethod_is_gc(PyObject *self)
     428{
     429        return 1;
     430}
     431#endif
  • trunk/src/libs/xpcom18a4/python/src/PyXPCOM.h

    r101955 r102380  
    586586        static NS_EXPORT_STATIC_MEMBER_(PyTypeObject *) s_pType;
    587587        static PyTypeObject *GetTypeObject(void);
     588        static int PyTypeMethod_is_gc(PyObject *self);
    588589#endif
    589590        static NS_EXPORT_STATIC_MEMBER_(PyMethodDef) methods[];
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette