Skip to content

Commit 05d7ff1

Browse files
committed
remove faulthandler._read_null()
Reading from NULL is an undefined behavior and `faulthandler` should not check for low-level C about undefined behaviors.
1 parent 130da64 commit 05d7ff1

File tree

2 files changed

+0
-38
lines changed

2 files changed

+0
-38
lines changed

Lib/test/test_faulthandler.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -166,29 +166,6 @@ def check_windows_exception(self, code, line_number, name_regex, **kw):
166166
fatal_error = 'Windows fatal exception: %s' % name_regex
167167
self.check_error(code, line_number, fatal_error, **kw)
168168

169-
@unittest.skipIf(sys.platform.startswith('aix'),
170-
"the first page of memory is a mapped read-only on AIX")
171-
def test_read_null(self):
172-
if not MS_WINDOWS:
173-
self.check_fatal_error("""
174-
import faulthandler
175-
faulthandler.enable()
176-
faulthandler._read_null()
177-
""",
178-
3,
179-
# Issue #12700: Read NULL raises SIGILL on Mac OS X Lion
180-
'(?:Segmentation fault'
181-
'|Bus error'
182-
'|Illegal instruction)')
183-
else:
184-
self.check_windows_exception("""
185-
import faulthandler
186-
faulthandler.enable()
187-
faulthandler._read_null()
188-
""",
189-
3,
190-
'access violation')
191-
192169
@skip_segfault_on_android
193170
def test_sigsegv(self):
194171
self.check_fatal_error("""

Modules/faulthandler.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,17 +1069,6 @@ faulthandler_suppress_crash_report(void)
10691069
#endif
10701070
}
10711071

1072-
static PyObject*
1073-
faulthandler_read_null(PyObject *self, PyObject *Py_UNUSED(args))
1074-
{
1075-
volatile int *x;
1076-
volatile int y;
1077-
1078-
faulthandler_suppress_crash_report();
1079-
x = NULL;
1080-
y = *x;
1081-
return PyLong_FromLong(y);
1082-
}
10831072

10841073
static void
10851074
faulthandler_raise_sigsegv(void)
@@ -1304,10 +1293,6 @@ static PyMethodDef module_methods[] = {
13041293
"Unregister the handler of the signal "
13051294
"'signum' registered by register().")},
13061295
#endif
1307-
{"_read_null", faulthandler_read_null, METH_NOARGS,
1308-
PyDoc_STR("_read_null($module, /)\n--\n\n"
1309-
"Read from NULL, raise "
1310-
"a SIGSEGV or SIGBUS signal depending on the platform.")},
13111296
{"_sigsegv", faulthandler_sigsegv, METH_VARARGS,
13121297
PyDoc_STR("_sigsegv($module, release_gil=False, /)\n--\n\n"
13131298
"Raise a SIGSEGV signal.")},

0 commit comments

Comments
 (0)