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
Compiler warnings in ubsan builds #85170
Comments
I'm seeing several compiler warnings in ubsan builds: $ ./configure --with-address-sanitizer --with-undefined-behavior-sanitizer
$ make clean
$ make
Parser/string_parser.c: In function ‘decode_unicode_with_escapes’:
Parser/string_parser.c:98:17: warning: null destination pointer [-Wformat-overflow=]
98 | sprintf(p, "\\U%08x", chr);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
Parser/string_parser.c:98:17: warning: null destination pointer [-Wformat-overflow=]
Parser/string_parser.c:98:17: warning: null destination pointer [-Wformat-overflow=]
In function ‘assemble_lnotab’,
inlined from ‘assemble_emit’ at Python/compile.c:5697:25,
inlined from ‘assemble’ at Python/compile.c:6036:18:
Python/compile.c:5651:19: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
5651 | *lnotab++ = k;
| ~~~~~~~~~~^~~
Objects/unicodeobject.c: In function ‘xmlcharrefreplace’:
Objects/unicodeobject.c:849:16: warning: null destination pointer [-Wformat-overflow=]
849 | str += sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Objects/unicodeobject.c:849:16: warning: null destination pointer [-Wformat-overflow=]
Objects/unicodeobject.c:849:16: warning: null destination pointer [-Wformat-overflow=]
Python/pylifecycle.c: In function ‘Py_FinalizeEx’:
Python/pylifecycle.c:1339:25: warning: unused variable ‘interp’ [-Wunused-variable]
1339 | PyInterpreterState *interp = tstate->interp;
| |
PR 20929 addresses three out of four warnings found by GCC 10's ubsan on Fedora 32. |
I see more warnings and a new leak detection on latest master: gcc -pthread -c -fsanitize=undefined -fsanitize=address -fno-omit-frame-pointer -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Objects/codeobject.o Objects/codeobject.c ==669952==ERROR: LeakSanitizer: detected memory leaks Direct leak of 57 byte(s) in 1 object(s) allocated from: |
Sorry, I meant to add Eric S. :) |
Too many Eric S's! |
Usually, it's not that the subinterpreter work introduces new leak, but makes old leak suddenly visible. The create_filter() leak was introduced way earlier: commit 9b99747
It's a minor leak since the create_filter() function is called exactly 5 times at startup. It's a leak of 5 strong references, it's not a big deal :-) |
Is there anything left to do here? |
I don't think so. |
xmlcharrefreplace():
If sprintf() can return a negative value, a Python exception must be raised when returning NULL. Otherwise, you get a SystemError (return NULL without raising an exception). |
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: