GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-91960: Skip test_gdb if gdb cannot retrive Python frames by vstinner · Pull Request #108999 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Sep 6, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

When Python is built with "clang -Og", gdb can fail to retrive the 'frame' parameter of _PyEval_EvalFrameDefault(). In this case, tests like py_bt() are likely to fail. Without getting access to Python frames, python-gdb.py is mostly clueless on retrieving the Python traceback.

  • Issue: Add FreeBSD build and test using Cirrus-CI #91960

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting core review tests Tests in the Lib/test dir labels Sep 6, 2023
@bedevere-bot bedevere-bot mentioned this pull request Sep 6, 2023
Add FreeBSD build and test using Cirrus-CI #91960
Closed
@vstinner

vstinner commented Sep 6, 2023

Copy link
Copy Markdown
Member Author

Without my PR, test on FreeBSD 13.2 with clang version 14.0.5: FAILURE

  • git clean -fdx; ./configure --with-pydebug && make clean && make && ./python -m test -v test_gdb -u all
  • Total tests: run=46 failures=4 skipped=9

Tests with my PR.

Linux, clang 16

Test on Linux, Fedora 38 with clang version 16.0.6 (Fedora 16.0.6-2.fc38):

  • clang -Og: SUCCESS with... 41 skipped tests on 46 :-)

    • git clean -fdx; ./configure --with-pydebug && make clean && make && ./python -m test -v test_gdb -u all
    • Total tests: run=46 skipped=41
  • clang -O0: SUCCESS with only 1 test skipped!

    • git clean -fdx; ./configure --with-pydebug CFLAGS="-O0" && make clean && make && ./python -m test -v test_gdb -u all
    • Total tests: run=46 skipped=1
    • test_print_after_up() is skipped because of: "Unable to read information on python frame"

FreeBSD, clang 14

Test on FreeBSD 13.2 with clang version 14.0.5:

  • clang -Og: SUCCESS with... 41 skipped tests on 46 :-)

    • git clean -fdx; ./configure --with-pydebug && make clean && make && ./python -m test -v test_gdb -u all
    • Total tests: run=46 skipped=41
  • clang -O0: SUCCESS with only 1 test skipped!

  • git clean -fdx; ./configure --with-pydebug CFLAGS="-O0" && make clean && make && ./python -m test -v test_gdb -u all

  • Total tests: run=46 skipped=1

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
pythongh-91960: Skip test_gdb if gdb cannot retrive Python frames
66a5f76
Skip test_gdb if gdb is unable to retrieve Python frame objects: if a
frame is "<optimized out>". When Python is built with "clang -Og",
gdb can fail to retrive the 'frame' parameter of
_PyEval_EvalFrameDefault(). In this case, tests like py_bt() are
likely to fail. Without getting access to Python frames,
python-gdb.py is mostly clueless on retrieving the Python traceback.
Moreover, test_gdb is no longer skipped on macOS if Python is built
with Clang.
@vstinner
vstinner force-pushed the test_gdb_clang branch from 542c061 to 66a5f76 Compare September 6, 2023 13:50
@vstinner

vstinner commented Sep 6, 2023

Copy link
Copy Markdown
Member Author

UPDATE: Moreover, test_gdb is no longer skipped on macOS if Python is built with Clang.

diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index c05a2d387c..ca50574e46 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -55,10 +55,6 @@ def get_gdb_version():
 if not sysconfig.is_python_build():
     raise unittest.SkipTest("test_gdb only works on source builds at the moment.")
 
-if 'Clang' in platform.python_compiler() and sys.platform == 'darwin':
-    raise unittest.SkipTest("test_gdb doesn't work correctly when python is"
-                            " built with LLVM clang")
-
 if ((sysconfig.get_config_var('PGO_PROF_USE_FLAG') or 'xxx') in
     (sysconfig.get_config_var('PY_CORE_CFLAGS') or '')):
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Sep 6, 2023
gh-91960: skip test_gdb when built with clang #108993
Closed
gh-91960: Add FreeBSD build and test using Cirrus-CI #91961
Merged
emaste
emaste approved these changes Sep 6, 2023
View reviewed changes
@vstinner

vstinner commented Sep 6, 2023

Copy link
Copy Markdown
Member Author

Test with my PR and clang -O3.

Test on Linux: SUCCESS with only 18 skipped tests on 46, nice!

  • git clean -fdx; ./configure --with-pydebug CC=clang && make clean && make && ./python -m test -v test_gdb -u all
  • Total tests: run=46 skipped=18

Test on FreeBSD: SUCCESS with only 18 skipped tests on 46, nice!

  • git clean -fdx; ./configure && make clean && make && ./python -m test -v test_gdb -u all
  • Total tests: run=46 skipped=18
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 6, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Now I have doubts about my tests on Linux :-( I'm not sure that I passed CC=clang to configure!

I redone my tests on Linux:

  • clang -O0: SUCCESS

    • git clean -fdx; ./configure CC=clang -with-pydebug CFLAGS="-O0" && make clean && make && ./python -m test -v test_gdb -u all
    • Total tests: run=46 skipped=1
    • grep -E '^(CC=|OPT=)' Makefile: CC=clang and OPT=-g -Og -Wall
  • clang -Og: SUCCESS

    • git clean -fdx; ./configure CC=clang -with-pydebug && make clean && make && ./python -m test -v test_gdb -u all
    • Total tests: run=46 skipped=41
    • grep -E '^(CC=|OPT=)' Makefile: CC=clang and OPT=-g -Og -Wall
  • clang -O3: SUCCESS

    • git clean -fdx; ./configure CC=clang && make clean && make && ./python -m test -v test_gdb -u all
    • Total tests: run=46 skipped=18
    • grep -E '^(CC=|OPT=)' Makefile: CC=clang and OPT=-DNDEBUG -g -O3 -Wall

Oh ok, we are safe :-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 6, 2023

Copy link
Copy Markdown
Member Author

GitHub Action jobs:

  • Ubuntu: test_gdb passed, Python is built with gcc -g -Og
  • Address sanitizer: "test_gdb passed", Python is built with gcc -DNDEBUG -g -O3
  • macOS: test_gdb skipped -- Couldn't find gdb on the path
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner enabled auto-merge (squash) September 6, 2023 14:24
@emaste

emaste commented Sep 6, 2023

Copy link
Copy Markdown
Contributor

Clang just treats -Og as an alias for -O1, so it's not surprising that the debuginfo quality is not as good as GCC's.
llvm/llvm-project@d340ccc

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner merged commit fbce43a into python:main Sep 6, 2023
@vstinner
vstinner deleted the test_gdb_clang branch September 6, 2023 14:34
@bedevere-bot bedevere-bot removed the awaiting core review label Sep 6, 2023
sorcio
sorcio reviewed Sep 6, 2023
View reviewed changes
Comment thread Lib/test/test_gdb.py
'Unable to read information on python frame',
# gh-91960: On Python built with "clang -Og", gdb gets
# "frame=<optimized out>" for _PyEval_EvalFrameDefault() parameter
'(unable to read python frame information)',

@sorcio sorcio Sep 6, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Any idea why libpython.py prints this rather than "Unable to read information on python frame"? It's possible that there are just some spots that you missed back in #19081

I'm also afraid that this speaks of a fragility of this approach. When optimizations are enabled, it's not easy to predict exactly what is going to be missing. But I'm happy that this allows to re-enable tests on platforms that were entirely ignored.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Sep 6, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Any idea why libpython.py prints this rather than "Unable to read information on python frame"? It's possible that there are just some spots that you missed back in #19081

It's likely possible to unify python-gdb.py logs, or use a different regex to match both cases :-) The (unable to read ...) format is for py-bt command. Depending on the command, the log is displayed differently. I took the lazy way of just matching the two strings.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner vstinner added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Sep 6, 2023
@miss-islington

miss-islington commented Sep 6, 2023

Copy link
Copy Markdown
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Sep 6, 2023

Copy link
Copy Markdown
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 6, 2023
@vstinner @miss-islington
pythongh-91960: Skip test_gdb if gdb cannot retrive Python frames (py…
ae655df
…thonGH-108999)

Skip test_gdb if gdb is unable to retrieve Python frame objects: if a
frame is "<optimized out>". When Python is built with "clang -Og",
gdb can fail to retrive the 'frame' parameter of
_PyEval_EvalFrameDefault(). In this case, tests like py_bt() are
likely to fail. Without getting access to Python frames,
python-gdb.py is mostly clueless on retrieving the Python traceback.
Moreover, test_gdb is no longer skipped on macOS if Python is built
with Clang.
(cherry picked from commit fbce43a)

Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot

bedevere-bot commented Sep 6, 2023

Copy link
Copy Markdown

GH-109010 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 6, 2023
@vstinner @miss-islington
pythongh-91960: Skip test_gdb if gdb cannot retrive Python frames (py…
ecf0033
…thonGH-108999)

Skip test_gdb if gdb is unable to retrieve Python frame objects: if a
frame is "<optimized out>". When Python is built with "clang -Og",
gdb can fail to retrive the 'frame' parameter of
_PyEval_EvalFrameDefault(). In this case, tests like py_bt() are
likely to fail. Without getting access to Python frames,
python-gdb.py is mostly clueless on retrieving the Python traceback.
Moreover, test_gdb is no longer skipped on macOS if Python is built
with Clang.
(cherry picked from commit fbce43a)

Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Sep 6, 2023
@bedevere-bot

bedevere-bot commented Sep 6, 2023

Copy link
Copy Markdown

GH-109011 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Sep 6, 2023
vstinner added a commit that referenced this pull request Sep 6, 2023
@miss-islington @vstinner
[3.11] gh-91960: Skip test_gdb if gdb cannot retrive Python frames (G…
d61b8f9
…H-108999) (#109011)

gh-91960: Skip test_gdb if gdb cannot retrive Python frames (GH-108999)

Skip test_gdb if gdb is unable to retrieve Python frame objects: if a
frame is "<optimized out>". When Python is built with "clang -Og",
gdb can fail to retrive the 'frame' parameter of
_PyEval_EvalFrameDefault(). In this case, tests like py_bt() are
likely to fail. Without getting access to Python frames,
python-gdb.py is mostly clueless on retrieving the Python traceback.
Moreover, test_gdb is no longer skipped on macOS if Python is built
with Clang.
(cherry picked from commit fbce43a)

Co-authored-by: Victor Stinner <[email protected]>
@vstinner vstinner mentioned this pull request Sep 7, 2023
test_gdb fails on PPC64LE Fedora Stable Clang 3.x buildbot #109053
Closed
@vstinner

vstinner commented Sep 7, 2023

Copy link
Copy Markdown
Member Author

Sadly, this change wasn't enough to fix PPC64LE Fedora Stable Clang 3.x: I created issue #109053.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Yhg1s pushed a commit that referenced this pull request Sep 8, 2023
@miss-islington @vstinner
[3.12] gh-91960: Skip test_gdb if gdb cannot retrive Python frames (G…
4b749ba
…H-108999) (#109010)

gh-91960: Skip test_gdb if gdb cannot retrive Python frames (GH-108999)

Skip test_gdb if gdb is unable to retrieve Python frame objects: if a
frame is "<optimized out>". When Python is built with "clang -Og",
gdb can fail to retrive the 'frame' parameter of
_PyEval_EvalFrameDefault(). In this case, tests like py_bt() are
likely to fail. Without getting access to Python frames,
python-gdb.py is mostly clueless on retrieving the Python traceback.
Moreover, test_gdb is no longer skipped on macOS if Python is built
with Clang.
(cherry picked from commit fbce43a)

Co-authored-by: Victor Stinner <[email protected]>
@sorcio sorcio mentioned this pull request Sep 11, 2023
Have debug builds support gdb extension by default #109270
Closed
@vstinner vstinner mentioned this pull request Sep 13, 2023
PPC64LE Fedora Stable Clang 3.x fails test_gdb #104736
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers
@sorcio sorcio sorcio left review comments
@emaste emaste emaste approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@vstinner @emaste @miss-islington @bedevere-bot @sorcio
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.