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
android: test_faulthandler fails #71121
Comments
test_faulthandler fails on an android emulator running an x86 system image at API level 21. See the attached test_output.txt file. |
The 8 failures are all because exitcode is 0 when it should not be. self.assertNotEqual(exitcode, 0)
AssertionError: 0 == 0 |
Reproducing the code that is executed on the first failure (test_disable) gives: On linux:
$ python
Python 3.6.0a0 (default:47fa003aa9f1, Feb 24 2016, 13:09:02)
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import faulthandler
>>> faulthandler.enable()
>>> faulthandler.disable()
True
>>> faulthandler._sigsegv()
Segmentation fault (core dumped)
On the android emulator:
root@generic_x86:/data/local/tmp # python
Python 3.6.0a0 (default:811ccdee6f87+, May 7 2016, 09:02:21)
[GCC 4.9 20140827 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import faulthandler
>>> faulthandler.enable()
>>> faulthandler.disable()
True
>>> faulthandler._sigsegv()
>>> |
The gdb backtrace of running interactively 'faulthandler._sigsegv()'. After the SIGSEGV and the last gdb 'continue', python is still alive with a '>>>' prompt and ready for the next user input: (gdb) b faulthandler_sigsegv Breakpoint 1, faulthandler_sigsegv (self=self@entry=<module at remote 0xb6d85cf4>, Program received signal SIGSEGV, Segmentation fault. |
This is due to something mysterious in Android's bionic & kernel. For the following C program: #include <stdlib.h>
#include <signal.h>
#include <stdio.h>
int main()
{
sigaction(SIGSEGV, NULL, NULL);
raise(SIGSEGV);
printf("Good evening!\n");
return 0;
} Compiled with: /opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc test_sigsegv.c --sysroot /opt/android-ndk/platforms/android-21/arch-arm -fPIE -Wl,-pie On ASUS ZE500KL: On Linux: (Compiled with gcc test_sigsegv.c) Seems the sigaction() call in Python occurs in Modules/signalmodule.c. |
Please try without "sigaction(SIGSEGV, NULL, NULL);". Does the program still quit? |
Does faulthandler._read_null() crash Python? If yes, I should patch test_faulthandler to replace all _sigsegv() with faulthandler._read_null(). I was too lazy to do that because currently the unit tests checks the exact error message, whereas _read_null() gives different error messages depending on the platform. |
Nope. int main()
{
raise(SIGSEGV);
} Still exits normally with 0.
Yes. int main()
{
int *x = 0;
int y = *x;
return 0;
} Is killed and exits with 139 as expected. |
root@generic_x86:/data/local/tmp # python
Python 3.6.0a0 (default:eee959fee5f5+, May 14 2016, 13:43:41)
[GCC 4.9 20150123 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import faulthandler
>>> faulthandler._read_null()
Segmentation fault |
The problem: raise() does not cause the program to exit in a Python interactive session and a spawned Python process exits with 0. Android fixed this problem at API level 24 (Android 6.0 aka Marshmallow). |
Can you try to write a decorator to not suplicate the same long skipIf()? |
Thanks for the suggestion Victor. The decorator may be used in other tests as well, and referring to the concern raised by Chi Hsuan in msg280147 and my answer, it makes it more clear that the build time _android_api_level should not be used in the standard library itself. |
New patch following Victor code review. |
buggy_raise_3.patch LGTM but I don't think that it's worth it to add @requires_raise to support directly. I suggest to only add it to test_faulthandler.py. |
New patch. |
buggy_raise_4.patch LGTM. Thanks for your patience :-) Maybe later you can also modify existing tests to use the new |
No problem, your suggestions and code reviews are always very much welcome :) |
New patch using a plain 'requires_raise' decorator without argument. |
LGTM. |
Oh, you didn't push your patch yet? Go ahead. buggy_raise_5.patch LGTM and is better than perfect :-) |
New changeset 66aac9676a28 by Xavier de Gaye in branch 'default': |
New changeset f37ac1a003f3 in branch 3.6. |
Buildbots fail since _ANDROID_API_LEVEL could end up being None |
New changeset 2639afcedaad by Xavier de Gaye in branch '3.6': New changeset 4012e28539c4 by Xavier de Gaye in branch 'default': |
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: