GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — segfault in mmap object when using __index__ method that closes the mmap · Issue #103987 · python/cpython Closed Labels 3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump DescriptionThe following (artificial) code segfaults CPython (I tried a bunch of versions, including git main) on my x86 Ubuntu Linux 22.10: import mmap with open("abcds", "w+") as f: f.write("foobar") f.flush() class X(object): def __index__(self): m.close() return 1 m = mmap.mmap(f.fileno(), 6, access=mmap.ACCESS_READ) print(m[1]) print(m[X()]) The problem is this code in static PyObject * mmap_subscript(mmap_object *self, PyObject *item) { CHECK_VALID(NULL); if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) return NULL; if (i < 0) i += self->size; if (i < 0 || i >= self->size) { PyErr_SetString(PyExc_IndexError, "mmap index out of range"); return NULL; } return PyLong_FromLong(Py_CHARMASK(self->data[i])); ... the Linked PRsReacted by sunmy2019 Activity
MetadataMetadataAssigneesLabels3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |