-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Valgrind warning in PyUnicode_Decode: false alarm with GCC builtin strcmp() #82299
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
Comments
Running tokenize.py in Valgrind emits 2 warnings: $ ./configure --with-valgrind
$ make
$ echo|PYTHONMALLOC=malloc valgrind ./python Lib/tokenize.py (A) ==30746== Conditional jump or move depends on uninitialised value(s) (B) ==30746== Conditional jump or move depends on uninitialised value(s) Warning (A) goes away when Python is compiled with gcc -O1. Warning (B) is still present when Python is compiled with gcc -O0. It's unclear to me if it's a false alarm or a real issue. On Fedora, the issue can be seen with: echo|valgrind python3 /usr/lib64/python3.7/tokenize.py On Fedora 30, python3 is Python 3.7.4. Downstream Fedora issue: https://bugzilla.redhat.com/show_bug.cgi?id=1751208 |
==30746== Conditional jump or move depends on uninitialised value(s) Oh, this issue looks like a duplicate of bpo-38124 which has just been fixed by: New changeset 39de95b by Benjamin Peterson in branch 'master': |
I reopen the issue, the PyUnicode_Decode warning is not fixed yet. vstinner@apu$ echo|PYTHONMALLOC=malloc valgrind ./python Lib/tokenize.py |
This warning is a false alarm: the GCC builtin strcmp() function seems to read past the NUL byte. When recompiling Python with -fno-builtin GCC option, the warning is gone. The valgrind warning can be reproduced using attached valgrind_strcmp_warn.c: On Fedora 30 with:
GCC builtin strcmp() emits a false alarm in valgrind: it reads past the NUL $ gcc -O3 valgrind_strcmp_warn.c -o valgrind_strcmp_warn -D NDEBUG=1 -g && valgrind ./valgrind_strcmp_warn
(...)
==29173== Conditional jump or move depends on uninitialised value(s)
==29173== at 0x4011CB: PyUnicode_Decode.part.0 (valgrind_strcmp_warn.c:276)
==29173== by 0x4898F42: (below main) (in /usr/lib64/libc-2.29.so)
==29173==
==29173== Conditional jump or move depends on uninitialised value(s)
==29173== at 0x4011EE: PyUnicode_Decode.part.0 (valgrind_strcmp_warn.c:280)
==29173== by 0x4898F42: (below main) (in /usr/lib64/libc-2.29.so)
==29173==
==29173== Conditional jump or move depends on uninitialised value(s)
==29173== at 0x401221: PyUnicode_Decode.part.0 (valgrind_strcmp_warn.c:282)
==29173== by 0x4898F42: (below main) (in /usr/lib64/libc-2.29.so)
(...)
==29173== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0) versus $ gcc -O3 valgrind_strcmp_warn.c -o valgrind_strcmp_warn -D NDEBUG=1 -fno-builtin -g && valgrind ./valgrind_strcmp_warn
==29217== Memcheck, a memory error detector
(...)
==29217== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) |
The valgrind false alarm on GCC builtin strcmp() has been reported to the Valgrind bug tracker in 2011, with an update in 2012 and... nothing :-( curl worked around the issue by disabling valgrind on the impacted test: Passing "--partial-loads-ok=yes" to Valgrind has no effect... It became the default: |
It seems like Python 2.7 is not affected. |
Ok, the issue has been fixed in 3.7, 3.8 and master branches. Ensure that you use Valgrind with Misc/valgrind.supp. Example: $ echo|PYTHONMALLOC=malloc valgrind --suppressions=Misc/valgrind-python.supp ./python Lib/tokenize.py
(...)
==12923== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 1 from 1) I close 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: