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

The compiler may optimise away globals with debug offsets #129223

Open
pablogsal opened this issue Jan 23, 2025 · 5 comments
Open

The compiler may optimise away globals with debug offsets #129223

pablogsal opened this issue Jan 23, 2025 · 5 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@pablogsal
Copy link
Member

pablogsal commented Jan 23, 2025

Bug report

Bug description:

When compiling with LTO and other aggressive optimization levels, is possible that the compiler will optimise away globals containing debug offsets. This is currently happening in https://buildbot.python.org/#/builders/125/builds/6895 for the new AsyncioDebug section, making the test fail because the information is not burned in the binary.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@pablogsal pablogsal added the type-bug An unexpected behavior, bug, or error label Jan 23, 2025
@picnixz picnixz added the performance Performance or resource usage label Jan 23, 2025
@picnixz
Copy link
Member

picnixz commented Jan 23, 2025

(Tagging it as performance even though it's probably a tiny tiny regression)

@pablogsal
Copy link
Member Author

pablogsal commented Jan 23, 2025

This is the fix of #124640 (comment)

What regression are you referring to?

@picnixz
Copy link
Member

picnixz commented Jan 23, 2025

IIUC, it's just that the compiler is not adding some additional information so, because of this additional information, the final binary changes a bit (perhaps the profile itself is changed). Hence the "tiny tiny" (ok, the wording was probably a poor wording). Sorry if I misunderstood what happened though!

@pablogsal
Copy link
Member Author

IIUC, it's just that the compiler is not adding some additional information so, because of this additional information, the final binary changes a bit (perhaps the profile itself is changed). Hence the "tiny tiny" (ok, the wording was probably a poor wording). Sorry if I misunderstood what happened though!

Hummm, seems that I didn't explain myself correctly. Apologies!

So what's happening here is that we rely on a global variable compiled in a very specific way to be present in the asyncio module shared object. Unfortunately as nothing else is using the symbol that means that the compiler when using LTO is deciding that as nobody uses the symbol then is safe to remove. This means that the section is never burned into the final shared object and we cannot do the external inspection.

The fix doesn't have performance implications: is basically convincing the compiler to leave the global alone even if is not used anywhere apparently :)

@picnixz picnixz added extension-modules C modules in the Modules dir topic-asyncio and removed performance Performance or resource usage labels Jan 23, 2025
@github-project-automation github-project-automation bot moved this to Todo in asyncio Jan 23, 2025
pablogsal added a commit to pablogsal/cpython that referenced this issue Jan 23, 2025
@picnixz
Copy link
Member

picnixz commented Jan 23, 2025

Oh that's not even an asyncio issue!

@picnixz picnixz removed this from asyncio Jan 23, 2025
@picnixz picnixz added interpreter-core (Objects, Python, Grammar, and Parser dirs) and removed extension-modules C modules in the Modules dir labels Jan 23, 2025
pablogsal added a commit to pablogsal/cpython that referenced this issue Jan 23, 2025
…or debug sections

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
pablogsal added a commit to pablogsal/cpython that referenced this issue Jan 23, 2025
…or debug sections

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
pablogsal added a commit to pablogsal/cpython that referenced this issue Jan 23, 2025
…or debug sections

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
pablogsal added a commit to pablogsal/cpython that referenced this issue Jan 23, 2025
…or debug sections

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
pablogsal added a commit to pablogsal/cpython that referenced this issue Jan 23, 2025
…or debug sections

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
pablogsal added a commit to pablogsal/cpython that referenced this issue Jan 23, 2025
…or debug sections

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
pablogsal added a commit to pablogsal/cpython that referenced this issue Jan 23, 2025
…or debug sections

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants