This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bstaletic
Recipients bstaletic
Date 2020-10-27.18:52:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1603824745.38.0.0631624355024.issue42176@roundup.psfhosted.org>
In-reply-to
Content
When running valgrind on a C code that calls `PyUnicode_AsEncodedString` and `PyUnicode_Decode`, valgrind reports that there's a conditional jump based on uninitialized variable, if the encoding is "latin1".

I am able to replicate the error 100% of the time, on Ubuntu 20.04, with python 3.9.0 installed with pyenv. I also have repro'd the error in my CI (link below). Steps to repro:

1. docker run -it ubuntu:20.04 /bin/bash
2. apt update
3. apt install valgrind gcc build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
4. curl https://pyenv.run | bash
5. export PATH="/root/.pyenv/bin:$PATH"
6. eval "$(pyenv init -)"
7. PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.9.0
8. Take the attached C file.
9. gcc -ggdb3 -I/root/.pyenv/versions/3.9.0/include/python3.9 -L/root/.pyenv/versions/3.9.0/lib test2.c -lpython3.9
10. LD_LIBRARY_PATH=/root/.pyenv/versions/3.9.0/lib/ PYTHONMALLOC=malloc valgrind ./a.out

Valgrind output:

==22783== Conditional jump or move depends on uninitialised value(s)
==22783==    at 0x49ABE64: PyUnicode_Decode (unicodeobject.c:3443)
==22783==    by 0x49ABE64: PyUnicode_Decode (unicodeobject.c:3398)
==22783==    by 0x109251: main (test2.c:5)
==22783==
==22783== Conditional jump or move depends on uninitialised value(s)
==22783==    at 0x499A294: PyUnicode_AsEncodedString (unicodeobject.c:3732)
==22783==    by 0x499A294: PyUnicode_AsEncodedString (unicodeobject.c:3688)
==22783==    by 0x10926D: main (test2.c:6)


CI log: https://dev.azure.com/borisstaletic/3ce92110-caa5-4c49-b8c3-44a433da676b/_apis/build/builds/1338/logs/6
Repository for testing the bug: https://github.com/bstaletic/ycmd/tree/python-error
History
Date User Action Args
2020-10-27 18:52:25bstaleticsetrecipients: + bstaletic
2020-10-27 18:52:25bstaleticsetmessageid: <1603824745.38.0.0631624355024.issue42176@roundup.psfhosted.org>
2020-10-27 18:52:25bstaleticlinkissue42176 messages
2020-10-27 18:52:25bstaleticcreate