Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0a160bf

Browse files
authored
gh-133157: remove usage of_Py_NO_SANITIZE_UNDEFINED infaulthandler (#134047)
In `faulthandler_sigfpe()`, instead of using 1/0 arithmetic, we explicitly raise SIGFPE.We also remove `faulthandler._read_null()` since reading from NULL is an undefinedbehavior and `faulthandler` should not check for low-level C undefined behaviors.
1 parent22e4a40 commit0a160bf

File tree

2 files changed

+2
-52
lines changed

2 files changed

+2
-52
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-
deftest_read_null(self):
172-
ifnotMS_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
deftest_sigsegv(self):
194171
self.check_fatal_error("""

‎Modules/faulthandler.c

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

1072-
staticPyObject*_Py_NO_SANITIZE_UNDEFINED
1073-
faulthandler_read_null(PyObject*self,PyObject*args)
1074-
{
1075-
volatileint*x;
1076-
volatileinty;
1077-
1078-
faulthandler_suppress_crash_report();
1079-
x=NULL;
1080-
y=*x;
1081-
returnPyLong_FromLong(y);
1082-
1083-
}
10841072

10851073
staticvoid
10861074
faulthandler_raise_sigsegv(void)
@@ -1158,23 +1146,12 @@ faulthandler_fatal_error_c_thread(PyObject *self, PyObject *args)
11581146
Py_RETURN_NONE;
11591147
}
11601148

1161-
staticPyObject*_Py_NO_SANITIZE_UNDEFINED
1149+
staticPyObject*
11621150
faulthandler_sigfpe(PyObject*self,PyObject*Py_UNUSED(dummy))
11631151
{
11641152
faulthandler_suppress_crash_report();
1165-
1166-
/* Do an integer division by zero: raise a SIGFPE on Intel CPU, but not on
1167-
PowerPC. Use volatile to disable compile-time optimizations. */
1168-
volatileintx=1,y=0,z;
1169-
z=x /y;
1170-
1171-
/* If the division by zero didn't raise a SIGFPE (e.g. on PowerPC),
1172-
raise it manually. */
11731153
raise(SIGFPE);
1174-
1175-
/* This line is never reached, but we pretend to make something with z
1176-
to silence a compiler warning. */
1177-
returnPyLong_FromLong(z);
1154+
Py_UNREACHABLE();
11781155
}
11791156

11801157
staticPyObject*
@@ -1316,10 +1293,6 @@ static PyMethodDef module_methods[] = {
13161293
"Unregister the handler of the signal "
13171294
"'signum' registered by register().")},
13181295
#endif
1319-
{"_read_null",faulthandler_read_null,METH_NOARGS,
1320-
PyDoc_STR("_read_null($module, /)\n--\n\n"
1321-
"Read from NULL, raise "
1322-
"a SIGSEGV or SIGBUS signal depending on the platform.")},
13231296
{"_sigsegv",faulthandler_sigsegv,METH_VARARGS,
13241297
PyDoc_STR("_sigsegv($module, release_gil=False, /)\n--\n\n"
13251298
"Raise a SIGSEGV signal.")},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp