Repository navigation
test_run_fileexflags() crash on PPC64LE RHEL7 LTO + PGO 3.x #118422
Copy link
Copy link
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortestsTests in the Lib/test dirTests in the Lib/test dir
on Apr 30, 2024 The bug can be reproduced just with these 2 tests:
$ cat bisect8 test.test_capi.test_misc.SubinterpreterTest.test_configured_settings test.test_capi.test_run.CAPITest.test_run_fileexflags $ ./python -m test test_capi -v --matchfile=bisect8Sometimes, I get the glibc error message:
Fatal error: glibc detected an invalid stdio handleThe crash is more likely if PYC files are removed:
rm -rf ./Lib/__pycache__ ./Lib/test/test_capi/__pycache__I cannot reproduce the issue with
gcc -O0andgcc -Og, only with a release build:gcc -O3.This buildbot uses an old GCC version:
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44).If it is only reproducible with a release build, would the following patch help?
diff --git a/Modules/_testcapi/run.c b/Modules/_testcapi/run.c index 4fd98b82d76..b35a12e9424 100644 --- a/Modules/_testcapi/run.c +++ b/Modules/_testcapi/run.c @@ -74,6 +74,7 @@ run_fileexflags(PyObject *mod, PyObject *pos_args) result = PyRun_FileExFlags(fp, filename, start, globals, locals, closeit, pflags); +#ifndef NDEBUG #if defined(__linux__) || defined(MS_WINDOWS) || defined(__APPLE__) /* The behavior of fileno() after fclose() is undefined, but it is * the only practical way to check whether the file was closed. @@ -85,6 +86,7 @@ run_fileexflags(PyObject *mod, PyObject *pos_args) return NULL; } #endif +#endif // NDEBUG if (!closeit && fileno(fp) < 0) { PyErr_SetString(PyExc_AssertionError, "Bad file descriptor after excution"); Py_XDECREF(result);
Or maybe just remove this dangerous implementation depending code?
Or maybe just remove this dangerous implementation depending code?
I wrote PR gh-118429 to use fstat() instead of relying on an undefined behavior of fileno() on a closed file.
Reacted by Serhiy Storchaka- added a commit that references this issue
on Apr 30, 2024
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
build: https://buildbot.python.org/all/#/builders/43/builds/5305/steps/5/logs/stdio
Logs:
Linked PRs