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_str.py crashes #45949
Comments
Checkout Python 2.5 from release25-maint branch, revision 59479 Compiled with gcc 4.3.0 20071212 , make test crashes with the following [... snip ...] |
gdb backtrace, segfaulting test is Lib/test/test_str.py |
Valgrind output, shows lots of invalid reads. |
What hardware and OS? 32 or 64 bit? What optimization level? Debug NB. Unless you used /Misc/valgrind-python.supp, the valgrind output is |
Linux 2.6.18, x86, 32bit . Executed valgrind with valgrind --suppressions=./Misc/valgrind-python.supp -v ./python attached as valgrind-supp.txt it still shows lots of invalid reads. Optimization level is -g -O3 which seems to be default as I didn't |
--enable-pydebug fixes the crash it might be that some uninitialized |
Looks like expandtabs() has a problem. Can you boil it down to a single |
BTW is this a released version of GCC? If not, you might want to file |
This is a soon to be released GCC though I won't deny it has And unless I can get a minimal C testcase, GCC bug will be worthless. Exact crashling call is string_tests.py line 255 : self.checkraises(OverflowError,
'\ta\n\tb', 'expandtabs', sys.maxint) Commenting out this fixes the crash. |
And the GCC authors always win these cases, C standard in hand.
If you want for me to debug this myself it'll be ages. it looks like '\ta\n\tb'.expandtabs(2147483647) Can you confirm that this crashes? If it does, you should be able to |
Actually, looking at the sample code and the string_expandtabs() This is very inconvenient because lots of buffer overflow protection I'm going to ask Martin von Loewis to give an opinion on this. Thanks for bringing this up! |
Indeed you are correct,
Program received signal SIGSEGV, Segmentation fault. Though I am not exactly sure how to proceed from here. |
Martin, can you look into this? It seems GCC 4.3 disables buffer |
1 similar comment
Martin, can you look into this? It seems GCC 4.3 disables buffer |
Guido, if you can give me a sample testcase I can bug GCC developers, this |
The example would be something like void foo(ssize_t x)
{
if (x >= 0) {
if (x+x < 0) printf("Overflow\n");
}
} main()
{
foo(2147483647);
} This should print "Overflow" but won't if the evil optimization |
Test always prints overflow here, tested with -O3 but here are /home/cartman/python-2.5/Modules/cPickle.c: In function 'Unpickler_noload': |
Following testcase doesn't print overflow with gcc 4.3 when compiled #include <sys/types.h>
#include <stdio.h>
void foo(ssize_t x)
{
if (x >= 0) {
if (x+x < 0) printf("Overflow\n");
}
} main()
{
volatile ssize_t x =2147483647;
foo(x);
} |
Reported as a gcc bug, http://gcc.gnu.org/PR34454 |
Ok so this is a code bug according to GCC developers see comment 1 & 2 |
I told you you can't win this argument with the GCC devs. We'll have to use -fwrapv or whatever. |
-fwrapv fixes the issue, thanks! |
Can you suggest a patch that adds this permanently, whenever it is supported? |
Looks like -fwrapv is there since gcc 2.95.3 attached patch adds -fwrapv |
After applying patch you need to run autoconf to update configure file Regards, |
Ok gcc developers say -fwrapv is there since gcc 3.3 so I think its Regards. |
GCC 2.96 is still the golden standard for me, and it doesn't like |
Attached patch exactly checks if compiler supports -fwrapv otherwise |
Last patch had a grammar error in comment, fix that. |
Committed revision 59483 (2.5 branch). Keeping this open since someone still needs to run autoconf to |
Thomas Heller ran autoconf for the trunk and submitted as r59485. (Thomas, could you run it in the 2.5 branch as well? I seem to have |
"""code that has been audited and fixed in the past will again be That code wasn't properly audited or fixed if it depended on integer Anyways, I'm glad we have the flag to disable the optimization on gcc in We should open a bug regarding fixing all of pythons integer overflows. I've opened http://bugs.python.org/issue1621 to track the larger code fix. |
Whatever, this is how overflow checks have been coded all over the code base. |
Guido van Rossum schrieb:
Done, see rev 59494. |
It would actually be better to use -fno-strict-overflow instead of See also http://bugs.python.org/issue1621 which suggests there aren't |
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: