Crash report
The following code will causes a segmentation fault:
>>> import decimal
>>> tp = type(decimal.Context().flags) # SignalDict type
>>> tp() # Segmentation fault
This code instantiates an object of SignalDict type (inherited from the base class SignalDictMixin) and tries to print the contents of the object (use repr).
The problem is caused by the following C code, where the signaldict_repr function accesses a null pointer.
static int
signaldict_init(PyObject *self, PyObject *args UNUSED, PyObject *kwds UNUSED)
{
SdFlagAddr(self) = NULL;
return 0;
}
...
static PyObject *
signaldict_repr(PyObject *self)
{
...
for (cm=signal_map, i=0; cm->name != NULL; cm++, i++) {
n[i] = cm->fqname;
// Access NULL pointer here
b[i] = SdFlags(self)&cm->flag ? "True" : "False";
}
...
}
Your environment
- CPython versions tested on: 3.13.0.0a0, 3.10.2
- Operating system and architecture: Ubuntu 22.04.1 LTS, Windows 11
Linked PRs
Crash report
The following code will causes a segmentation fault:
This code instantiates an object of
SignalDicttype (inherited from the base classSignalDictMixin) and tries to print the contents of the object (use repr).The problem is caused by the following C code, where the
signaldict_reprfunction accesses a null pointer.Your environment
Linked PRs
signaldict_repr#106270signaldict_reprin_decimalmodule (#… #107490signaldict_reprin_decimalmodule (#… #107491