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

test_gdb must not fail on "unexpected" messages written into stderr #81543

Closed
vstinner opened this issue Jun 21, 2019 · 10 comments
Closed

test_gdb must not fail on "unexpected" messages written into stderr #81543

vstinner opened this issue Jun 21, 2019 · 10 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

BPO 37362
Nosy @vstinner, @davidmalcolm, @miss-islington
PRs
  • bpo-37362: test_gdb now ignores stderr #14287
  • [3.8] bpo-37362: test_gdb now ignores stderr (GH-14287) #14295
  • [3.7] bpo-37362: test_gdb now ignores stderr (GH-14287) #14296
  • [2.7] bpo-37362: test_gdb now ignores stderr (GH-14287) #14297
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-06-21.22:17:13.084>
    created_at = <Date 2019-06-21.13:45:56.196>
    labels = ['3.8', '3.7', 'tests', '3.9']
    title = 'test_gdb must not fail on "unexpected" messages written into stderr'
    updated_at = <Date 2019-06-21.22:17:38.723>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-06-21.22:17:38.723>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-06-21.22:17:13.084>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2019-06-21.13:45:56.196>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37362
    keywords = ['patch']
    message_count = 10.0
    messages = ['346211', '346212', '346221', '346251', '346252', '346255', '346257', '346258', '346260', '346261']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'dmalcolm', 'miss-islington']
    pr_nums = ['14287', '14295', '14296', '14297']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue37362'
    versions = ['Python 2.7', 'Python 3.7', 'Python 3.8', 'Python 3.9']

    @vstinner
    Copy link
    Member Author

    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")

    @vstinner vstinner added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes tests Tests in the Lib/test dir labels Jun 21, 2019
    @vstinner
    Copy link
    Member Author

    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

    @davidmalcolm
    Copy link
    Member

    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.

    @vstinner
    Copy link
    Member Author

    New changeset e56a123 by Victor Stinner in branch 'master':
    bpo-37362: test_gdb now ignores stderr (GH-14287)
    e56a123

    @vstinner
    Copy link
    Member Author

    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 ;-)

    @miss-islington
    Copy link
    Contributor

    New changeset 16ec95b by Miss Islington (bot) in branch '3.7':
    bpo-37362: test_gdb now ignores stderr (GH-14287)
    16ec95b

    @miss-islington
    Copy link
    Contributor

    New changeset 3523e0c by Miss Islington (bot) in branch '3.8':
    bpo-37362: test_gdb now ignores stderr (GH-14287)
    3523e0c

    @vstinner
    Copy link
    Member Author

    New changeset adcdb1e by Victor Stinner in branch '2.7':
    bpo-37362: test_gdb now ignores stderr (GH-14287) (GH-14297)
    adcdb1e

    @vstinner
    Copy link
    Member Author

    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 python/cpython#63952: missing symbols on System Z
                'Missing separate debuginfo for ',
                'Try: zypper install -C ',
                )

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

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

    Issue bpo-19753: Try to fix test_gdb on SystemZ buildbot
    

    But I removed it in:

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

    Try to fix test_gdb on s390x buildbots
    

    @vstinner
    Copy link
    Member Author

    I closed the issue. test_gdb now ignores stderr in all branches.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants