Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

Conversation

@jerryjhird
Copy link

Initialize PyGILState_STATE gil_state to PyGILState_UNLOCKED in PyTraceMalloc_Track, tracemalloc_alloc, tracemalloc_realloc to stop -Wmaybe-uninitialized warnings on GCC. Behavior is unchanged

@python-cla-bot
Copy link

python-cla-bot bot commented Jan 30, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jan 30, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@jerryjhird jerryjhird changed the title [tracemalloc] initialize gil_state in functions to stop warnings [tracemalloc] initialize gil_state in functions to stop -Wmaybe-uninitialized warnings Jan 30, 2026
Initialize PyGILState_STATE gil_state to PyGILState_UNLOCKED in
PyTraceMalloc_Track, tracemalloc_alloc, tracemalloc_realloc to
stop -Wmaybe-uninitialized warnings on GCC. Behavior is unchanged
@jerryjhird jerryjhird force-pushed the tracemalloc-gilstate-fix branch from 9710396 to daeb949 Compare January 30, 2026 13:27
@bedevere-app
Copy link

bedevere-app bot commented Jan 30, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@vstinner
Copy link
Member

How did you build Python? What is your operating system name and version? What is your GCC version?

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialize gil_state in functions to stop -Wmaybe-uninitialized warnings

Sadly, GCC is wrong here, gil_state is always initialized and it's used. GCC is confused by if (need_gil).

PyTraceMalloc_Track(unsigned int domain, uintptr_t ptr,
size_t size)
{
PyGILState_STATE gil_state = PyGILState_UNLOCKED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not needed.

@jerryjhird
Copy link
Author

jerryjhird commented Jan 30, 2026

How did you build Python? What is your operating system name and version? What is your GCC version?

gcc (GCC) 15.2.1 20251211 (Red Hat 15.2.1-5)
Fedora Linux 42 (Workstation Edition) x86_64

initialize gil_state in functions to stop -Wmaybe-uninitialized warnings

Sadly, GCC is wrong here, gil_state is always initialized and it's used. GCC is confused by if (need_gil).

i see, sorry for wasting your time. should i close the pr or would you still want it just to suppress the warning?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants