New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_regrtest alters the execution environment on Android #76427
Comments
Sorry, this is a bit involved :-( Description:
Here is the command that is run remotely (through adb), the run_tests.py file is Tools/scripts/run_tests.py from the src tree that has been pushed to the emulator by buildbottest: python /data/local/tmp/python/bin/run_tests.py -j 1 -u all -W --slowest --fail-env-changed --timeout=900 -j2 test_regrtest The command also fails when replacing '-j2' with '-j1'. In that case:
In that case:
The fact that the TEMP directory is not clean already happens when running buildbottest natively with the standard Python Makefile (no one has noticed it yet I guess) and the directory contains a core file. This is another bug, related to this one and it provided a much welcome hint to use 'adb logcat' and for a work-around :-) Work-around
|
test_crashed() does crash on SIGGEV on purpose. It tests how regrtest behaves when a worker does crash. The exacty signal doesn't matter. This function uses faulthandler._sigsegv() which is supposed to "suppress crash report": see faulthandler_suppress_crash_report() in Modules/faulthandler.c, but also SuppressCrashReport in test/support/init.py. Maybe we need to disable the Android crash reporter as well? |
The root issue is likely the core file. I got a similar issue on FreeBSD when an unit test crashed on purpose but forgot to suppress crash report. You should either find a way to disable the creation of core file when using faulthandler_suppress_crash_report() and/or SuppressCrashReport, or skip the test on Android. I'm fine with skipped the test on Android, since the test currently uses faulthandler._sigsegv() which is already skipped on Android in test_faulthandler: def skip_segfault_on_android(test):
# Issue python/cpython#76319: Raising SIGSEGV on Android may not cause a crash.
return unittest.skipIf(is_android,
'raising SIGSEGV on Android is unreliable')(test) |
I should have written "happens on linux" instead of "happens when running buildbottest natively with the standard Python Makefile". I have now created bpo-32252 for that distinct problem. |
I agree that test_crashed() should be skipped on Android anyway and I will create a PR to skip the test. If I understand correctly, there may be another nasty bug that is revealed when test_regrstest fails with the environment altered:
I found a new point that may help understand this problem:
[1] This is the only location where a shell user may have both write and exec permissions, the Android applications have those permissions here too and in their own dedicated locations on /data/data. |
To debug and reproduce the problem on Android, one must checkout from the bpo-30386 branch c0ca089. faulthandler._sigsegv() does crash the crasher in test_crashed, so test_crashed must not be disabled.
Both test_crashed tests are run in nested tests directories (i.e. in $TEMPDIR/test_python_/test_python_) on Android. As a consequence the test_python_* directory that is not removed by the crasher because it crashed, is reported by test_crashed as altering the environment. This also explains the other points raised previously. A remote interactive shell is run by the 'adb shell' command and the TMPDIR environment variable is set in that shell. A command may be run remotely with the command 'adb shell /path/to/command' and the TMPDIR variable is *not set* (but most if not all the other shell environment variables are set) and since on Android /tmp does not exist, then tempfile.gettempdir() uses the current directory. This explains why the test directories are doubly nested. On the commit that is the child of commit c0ca089... which we are using here, TMPDIR has been made to be set in the script that runs Tools/script/run_tests.py and so it does fix inadvertently the issue for the reason explained in the previous paragraph. This bug can only exist on platforms where tempfile.gettempdir() falls back to using the current directory because '/tmp', '/var/tmp' and '/usr/tmp' do not exist and where none of the 'TMPDIR', 'TEMP', 'TMP' variables is set. Therefore we can either close this issue as not a bug or use the following patch that fixes the problem, it is similar to the fix made in bpo-15300: diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index 8364767b3a..3a213e12c4 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -468,10 +468,13 @@ class BaseTestCase(unittest.TestCase):
input = ''
if 'stderr' not in kw:
kw['stderr'] = subprocess.PIPE
+ savedcwd = (support.SAVEDCWD if
+ any(x.startswith('-j') for x in args) else None)
proc = subprocess.run(args,
universal_newlines=True,
input=input,
stdout=subprocess.PIPE,
+ cwd=savedcwd,
**kw)
if proc.returncode != exitcode:
msg = ("Command %s failed with exit code %s\n" |
This issue should be fixed by bpo-32252: commit 48d4dd9
If it's not the case. Please open the issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: