Skip to content
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

./Modules/_io/fileio.c:175:9: warning: ‘exc’ may be used uninitialized [-Wmaybe-uninitialized] #115739

Closed
mcepl opened this issue Feb 20, 2024 · 2 comments

Comments

@mcepl
Copy link
Contributor

mcepl commented Feb 20, 2024

PyObject *exc = NULL;
if (res == NULL) {
exc = PyErr_GetRaisedException();
}
if (self->finalizing) {
PyObject *r = fileio_dealloc_warn(self, (PyObject *) self);
if (r) {
Py_DECREF(r);
}
else {
PyErr_Clear();
}
}
rc = internal_close(self);
if (res == NULL) {
_PyErr_ChainExceptions1(exc);
}

When building Python 3.13.0a3 for openSUSE/Tumbleweed, we get this in the build log:

[  112s] make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/Python-3.13.0a3'
[  112s] gcc -I./Modules/_io -fno-strict-overflow -Wsign-compare -DNDEBUG -march=x86-64-v3 -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g -DOPENSSL_LOAD_CONF -fwrapv  -fno-semantic-interposition -march=x86-64-v3 -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g -IVendor/ -march=x86-64-v3 -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g -IVendor/  -fno-semantic-interposition -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -fprofile-generate -I./Include/internal -I./Include/internal/mimalloc  -I. -I./Include   -fPIC -DPy_BUILD_CORE_BUILTIN -c ./Modules/_io/fileio.c -o Modules/_io/fileio.o
[  112s] In function ‘_io_FileIO_close_impl’,
[  112s]     inlined from ‘_io_FileIO_close’ at ./Modules/_io/clinic/fileio.c.h:34:12:
[  112s] ./Modules/_io/fileio.c:175:9: warning: ‘exc’ may be used uninitialized [-Wmaybe-uninitialized]
[  112s]   175 |         _PyErr_ChainExceptions1(exc);
[  112s]       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[  112s] ./Modules/_io/fileio.c: In function ‘_io_FileIO_close’:
[  112s] ./Modules/_io/fileio.c:160:15: note: ‘exc’ was declared here
[  112s]   160 |     PyObject *exc;
[  112s]       |               ^~~
[  112s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/Python-3.13.0a3'

(Complete build log)

@mcepl mcepl changed the title ./Modules/_io/fileio.c:175:9: warning: “exc” may be used uninitialized [-Wmaybe-uninitialized] ./Modules/_io/fileio.c:175:9: warning: ‘exc’ may be used uninitialized [-Wmaybe-uninitialized] Feb 20, 2024
@sobolevn
Copy link
Member

Isn't it a duplicate of #114286?
If it is, then it will be fixed in https://github.com/python/cpython/releases/tag/v3.13.0a4

Can you please confirm?

@mcepl
Copy link
Contributor Author

mcepl commented Feb 20, 2024

Yes, it is. _PyErr_ChainExceptions1 can get NULL parameter, and it would be the only difference between my solution and the one in #114286.

@mcepl mcepl closed this as completed Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants