[New-bugs-announce] [issue42176] Valgrind reports "Conditional jump or move depends on uninitialised value(s)" in `PyUnicode_AsEncodedString` and `PyUnicode_Decode`

Boris Staletic report at bugs.python.org
Tue Oct 27 14:52:25 EDT 2020


New submission from Boris Staletic <boris.staletic at gmail.com>:

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

----------
components: Interpreter Core
files: test.c
messages: 379790
nosy: bstaletic
priority: normal
severity: normal
status: open
title: Valgrind reports "Conditional jump or move depends on uninitialised value(s)" in `PyUnicode_AsEncodedString` and `PyUnicode_Decode`
type: compile error
versions: Python 3.9
Added file: https://bugs.python.org/file49542/test.c

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42176>
_______________________________________


More information about the New-bugs-announce mailing list