VirtualBox

Changeset 102411 in vbox for trunk/src/libs/xpcom18a4


Ignore:
Timestamp:
Dec 1, 2023 8:53:30 AM (16 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160554
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 [3rd attempt, misunderstood what tp_is_gc is doing, we need to make all Py_nsIID objects as not GC'able]

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

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/Makefile.kmk

    r102317 r102411  
    8080 #
    8181 if exists "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9"
    82   VBOX_PYTHON39_INC = /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers
    83   VBOX_PYTHON39_LIB = /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/libpython3.9.dylib
     82  VBOX_PYTHON39_INC = /Users/aeichner/python-3.11.6/include/python3.11
     83  VBOX_PYTHON39_LIB = /Users/aeichner/python-3.11.6/lib/libpython3.9.dylib
    8484 endif
    8585 if exists "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8"
  • trunk/src/libs/xpcom18a4/python/src/PyIID.cpp

    r102401 r102411  
    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        };
     
    243244                /* .basicsize: */       sizeof(Py_nsIID),
    244245                /* .itemsize: */        0,
    245                 /* .flags: */           0,
     246                /* .flags: */           Py_TPFLAGS_DEFAULT,
    246247                /* .slots: */           aTypeSlots,
    247248        };
     
    320321Py_nsIID::PyTypeMethod_richcompare(PyObject *self, PyObject *other, int op)
    321322{
     323    nsIID iid;
     324    if (!Py_nsIID::IIDFromPyObject(other, &iid))
     325    {
     326        /* Can't do comparison betsides equality/inequalityif the other object does not contain an IID. */
     327        if (op == Py_EQ)
     328            Py_RETURN_FALSE;
     329        else if (op == Py_NE)
     330            Py_RETURN_TRUE;
     331
     332        PyErr_SetString(PyExc_TypeError, "Comparison between different object types is not defined");
     333        return NULL;
     334    }
     335
    322336    PyObject *result = NULL;
    323337        Py_nsIID *s_iid = (Py_nsIID *)self;
    324         Py_nsIID *o_iid = (Py_nsIID *)other;
    325         int rc = memcmp(&s_iid->m_iid, &o_iid->m_iid, sizeof(s_iid->m_iid));
     338        int rc = memcmp(&s_iid->m_iid, &iid, sizeof(s_iid->m_iid));
    326339    switch (op)
    327340    {
     
    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 0;
     430}
     431#endif
  • trunk/src/libs/xpcom18a4/python/src/PyXPCOM.h

    r102401 r102411  
    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.

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