This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_gdb must not fail on "unexpected" messages written into stderr
Type: Stage: resolved
Components: Tests Versions: Python 3.9, Python 3.8, Python 3.7, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: dmalcolm, miss-islington, vstinner
Priority: normal Keywords: patch

Created on 2019-06-21 13:45 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14287 merged vstinner, 2019-06-21 13:48
PR 14295 merged miss-islington, 2019-06-21 21:17
PR 14296 merged miss-islington, 2019-06-21 21:17
PR 14297 merged vstinner, 2019-06-21 21:28
Messages (10)
msg346211 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-21 13:45
Currently, test_gdb fails if gdb logs messages on stderr which are "unexpected". I don't understand the rationale for that: Python is not supposed to test gdb. It's only supposed to check that python-gdb.py commands work as expected: stderr should be ignored.

In the past, I was lazy and just added more and more patterns to ignore on stderr, but this approach doesn't work in the long term: gdb evolves frequently, and there are always new messages.

Attached PR modify test_gdb to ignore stderr, except of "PC not saved" pattern used to skip test_gdb on a special case: bpo-34007.

        # bpo34007: Sometimes some versions of the shared libraries that
        # are part of the traceback are compiled in optimised mode and the
        # Program Counter (PC) is not present, not allowing gdb to walk the
        # frames back. When this happens, the Python bindings of gdb raise
        # an exception, making the test impossible to succeed.
        if "PC not saved" in err:
            raise unittest.SkipTest("gdb cannot walk the frame object"
                                    " because the Program Counter is"
                                    " not present")
msg346212 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-21 13:51
> In the past, I was lazy and just added more and more patterns to ignore on stderr, but this approach doesn't work in the long term: gdb evolves frequently, and there are always new messages.

A recent example: test_gdb fails on Fedora because a warning which should not prevent to test python-gdb.py commands:

"Missing separate debuginfo for /lib/ld-linux-aarch64.so.1"

Moreover, Fedora also suggests a command to install missing package in this case:

"Try: dnf --enablerepo='*debug*' install ..."

https://bugzilla.redhat.com/show_bug.cgi?id=1721483
msg346221 - (view) Author: Dave Malcolm (dmalcolm) (Python committer) Date: 2019-06-21 14:31
I think when I wrote this I was over-optimistically thinking that we could just add more patterns, but if it's becoming a pain, then your approach looks good to me.
msg346251 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-21 21:17
New changeset e56a123fd0acaa295a28b98d2e46d956b97d1263 by Victor Stinner in branch 'master':
bpo-37362: test_gdb now ignores stderr (GH-14287)
https://github.com/python/cpython/commit/e56a123fd0acaa295a28b98d2e46d956b97d1263
msg346252 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-21 21:22
> I think when I wrote this I was over-optimistically thinking that we could just add more patterns, but if it's becoming a pain, then your approach looks good to me.

Well, I tried hard to fit into this approach: over the years, I added more and more patterns... but it's a painful work: first a CI break, I add more patterns and then I have to backport the change to all branches. As I wrote, I'm not convinced of the purpose of getting a failure in this case. Python doesn't get any benefit from this.

Anyway, I merged my change. Thanks for your approval ;-)
msg346255 - (view) Author: miss-islington (miss-islington) Date: 2019-06-21 21:38
New changeset 16ec95bb191e4136630de7437f75636d4b6a450f by Miss Islington (bot) in branch '3.7':
bpo-37362: test_gdb now ignores stderr (GH-14287)
https://github.com/python/cpython/commit/16ec95bb191e4136630de7437f75636d4b6a450f
msg346257 - (view) Author: miss-islington (miss-islington) Date: 2019-06-21 21:40
New changeset 3523e0c47be372477e990df7435a0f45be80fd50 by Miss Islington (bot) in branch '3.8':
bpo-37362: test_gdb now ignores stderr (GH-14287)
https://github.com/python/cpython/commit/3523e0c47be372477e990df7435a0f45be80fd50
msg346258 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-21 21:59
New changeset adcdb1e4f5eb3c63e4e40242737be9c00a26764c by Victor Stinner in branch '2.7':
bpo-37362: test_gdb now ignores stderr (GH-14287) (GH-14297)
https://github.com/python/cpython/commit/adcdb1e4f5eb3c63e4e40242737be9c00a26764c
msg346260 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-21 22:17
For the record, examples of ignored patterns:

        ignore_patterns = (
            'Function "%s" not defined.' % breakpoint,
            'Do you need "set solib-search-path" or '
            '"set sysroot"?',
            # BFD: /usr/lib/debug/(...): unable to initialize decompress
            # status for section .debug_aranges
            'BFD: ',
            # ignore all warnings
            'warning: ',
            )

Enjoy the older list before I chose to ignore "warning: " :-)

        # Ignore some benign messages on stderr.
        ignore_patterns = (
            'Function "%s" not defined.' % breakpoint,
            "warning: no loadable sections found in added symbol-file"
            " system-supplied DSO",
            "warning: Unable to find libthread_db matching"
            " inferior's thread library, thread debugging will"
            " not be available.",
            "warning: Cannot initialize thread debugging"
            " library: Debugger service failed",
            'warning: Could not load shared library symbols for '
            'linux-vdso.so',
            'warning: Could not load shared library symbols for '
            'linux-gate.so',
            'warning: Could not load shared library symbols for '
            'linux-vdso64.so',
            'Do you need "set solib-search-path" or '
            '"set sysroot"?',
            'warning: Source file is more recent than executable.',
            # Issue #19753: missing symbols on System Z
            'Missing separate debuginfo for ',
            'Try: zypper install -C ',
            )

Oh strange, "Missing separate debuginfo for " message was ignored!

commit f4a4898c18c9cc5ca6d2747789c6586524daf461
Author: Victor Stinner <victor.stinner@gmail.com>
Date:   Sun Nov 24 18:55:25 2013 +0100

    Issue #19753: Try to fix test_gdb on SystemZ buildbot

But I removed it in:

commit 904f5def5cc6da106a1e2e9feb0830cdb1433519
Author: Victor Stinner <victor.stinner@gmail.com>
Date:   Wed Mar 23 18:32:54 2016 +0100

    Try to fix test_gdb on s390x buildbots
msg346261 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-21 22:17
I closed the issue. test_gdb now ignores stderr in all branches.
History
Date User Action Args
2022-04-11 14:59:17adminsetgithub: 81543
2019-06-21 22:17:38vstinnersetmessages: + msg346261
2019-06-21 22:17:13vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg346260

stage: patch review -> resolved
2019-06-21 21:59:11vstinnersetmessages: + msg346258
2019-06-21 21:40:01miss-islingtonsetmessages: + msg346257
2019-06-21 21:38:30miss-islingtonsetnosy: + miss-islington
messages: + msg346255
2019-06-21 21:28:01vstinnersetpull_requests: + pull_request14121
2019-06-21 21:22:43vstinnersetmessages: + msg346252
2019-06-21 21:17:56miss-islingtonsetpull_requests: + pull_request14120
2019-06-21 21:17:48miss-islingtonsetpull_requests: + pull_request14119
2019-06-21 21:17:35vstinnersetmessages: + msg346251
2019-06-21 14:31:07dmalcolmsetnosy: + dmalcolm
messages: + msg346221
2019-06-21 13:51:32vstinnersetmessages: + msg346212
2019-06-21 13:48:53vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request14109
2019-06-21 13:45:56vstinnercreate