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_capi.test_no_FatalError_infinite_loop crash on Windows #53362

Closed
briancurtin opened this issue Jun 29, 2010 · 23 comments
Closed

test_capi.test_no_FatalError_infinite_loop crash on Windows #53362

briancurtin opened this issue Jun 29, 2010 · 23 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-windows tests Tests in the Lib/test dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@briancurtin
Copy link
Member

BPO 9116
Nosy @birkenfeld, @terryjreedy, @vsajip, @pitrou, @vstinner, @tjguk, @ezio-melotti, @briancurtin, @zware, @zooba
Dependencies
  • bpo-5619: Pass MS CRT debug flags into subprocesses
  • Files
  • py3k_fix_test_capi_crash.patch
  • test_capi.diff: Slight change to test assertion needed to pass on Windows
  • 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 = None
    created_at = <Date 2010-06-29.15:58:26.076>
    labels = ['interpreter-core', 'tests', 'OS-windows', 'type-crash']
    title = 'test_capi.test_no_FatalError_infinite_loop crash on Windows'
    updated_at = <Date 2014-10-14.17:11:48.119>
    user = 'https://github.com/briancurtin'

    bugs.python.org fields:

    activity = <Date 2014-10-14.17:11:48.119>
    actor = 'skrah'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Interpreter Core', 'Tests', 'Windows']
    creation = <Date 2010-06-29.15:58:26.076>
    creator = 'brian.curtin'
    dependencies = ['5619']
    files = ['18809', '25457']
    hgrepos = []
    issue_num = 9116
    keywords = ['patch']
    message_count = 22.0
    messages = ['108914', '108915', '110902', '112128', '112132', '112152', '113155', '115246', '115249', '115635', '115921', '115931', '116008', '121187', '121258', '149413', '150922', '159982', '160031', '160072', '182471', '222202']
    nosy_count = 13.0
    nosy_names = ['georg.brandl', 'terry.reedy', 'vinay.sajip', 'pitrou', 'vstinner', 'ocean-city', 'tim.golden', 'ezio.melotti', 'brian.curtin', 'catalin.iacob', 'python-dev', 'zach.ware', 'steve.dower']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue9116'
    versions = ['Python 3.4', 'Python 3.5']

    @briancurtin
    Copy link
    Member Author

    Debug and Release builds of py3k both throw up a Visual Studio debugger prompt when running this test on Windows. I don't have much time at the moment to investigate, but I find it odd that this isn't occurring on the two Windows py3k buildbots.

    Output of the release build after selecting not to debug:

    C:\python-dev\py3k>PCbuild\amd64\python.exe -m test.regrtest test_capi
    test_capi
    test test_capi failed -- Traceback (most recent call last):
      File "C:\python-dev\py3k\lib\test\test_capi.py", line 50, in test_no_FatalError_infinite_loop
        b'Fatal Python error:'
    AssertionError: b"Fatal Python error: PyThreadState_Get: no current thread\r\n\r
    \nThis application has requested the Runtime to terminate it in an unusual way.\
    nPlease contact the application's support team for more information." != b'Fatal
     Python error: PyThreadState_Get: no current thread'

    1 test failed:
    test_capi

    @briancurtin briancurtin added interpreter-core (Objects, Python, Grammar, and Parser dirs) tests Tests in the Lib/test dir type-crash A hard crash of the interpreter, possibly with a core dump labels Jun 29, 2010
    @briancurtin
    Copy link
    Member Author

    I should also note that this doesn't appear to happen on release31-maint or trunk.

    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Jul 20, 2010

    I experienced this crash on test_thread.py.

    I created a patch hopefully to fix this issue. My knowleage about
    threading is not so deep, so maybe this patch is not so good. ;-)

    # I'm worried about COND_RESET which is not used in my patch. But
    # pthread variant is doing nothing on this macro...

    Now, test_thread.py runs fine.

    Reference:
    http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
    http://msdn.microsoft.com/en-us/library/ms686293(VS.85).aspx
    http://www.linux.or.jp/JM/html/glibc-linuxthreads/man3/pthread_cond_init.3.html

    @ocean-city ocean-city mannequin added the release-blocker label Jul 31, 2010
    @pitrou
    Copy link
    Member

    pitrou commented Jul 31, 2010

    The patch shouldn't remove COND_RESET, otherwise there will be spurious wakeups.
    Also, it would be nice to have more precisions about the issue. At which point does PyThreadState_Get() fail?

    @pitrou
    Copy link
    Member

    pitrou commented Jul 31, 2010

    I don't have much time at the moment to investigate, but I find it odd > that this isn't occurring on the two Windows py3k buildbots.

    At least two of them (and perhaps the third -- I've asked Paul about it) are single-core virtual machines. What is your setup?

    @briancurtin
    Copy link
    Member Author

    Both machines I've seen this on were true multicore, no VMs. One is dual core the other is 16.

    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Aug 7, 2010

    I said I saw same crash on test_threading in msg110902, but there
    is possibility that this is different problem. So I'll remove my
    patch and clear dependencies I set.

    @florentx florentx mannequin added the OS-windows label Aug 10, 2010
    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Aug 30, 2010

    I see the same crash in test_capi, qemu, Windows 7, Debug|x64. The
    function crash_no_current_thread() introduced in r81142 ultimately
    calls Py_FatalError, which then aborts.

    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Aug 30, 2010

    I just see that the test is running as expected:

    _testcapi.crash_no_current_thread() is running in a subprocess, so
    the abort() is harmless on Linux. On Windows, abort() causes the
    pop-ups, apparently even when it occurs in a subprocess.

    Perhaps we should generally use an ABORT() macro, which translates to
    exit() on Windows.

    @birkenfeld
    Copy link
    Member

    Once again, this is not important enough block 3.2a2.

    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Sep 9, 2010

    After creating experimental patch, I could supress dialog
    and error message on VS8.0. But it seems there is no way to
    suppress error message on VC6. That is,

    FAILED (failures=1)
    Traceback (most recent call last):
      File "e:\python-dev\py3k\lib\runpy.py", line 160, in _run_module_as_main
        "__main__", fname, loader, pkg_name)
      File "e:\python-dev\py3k\lib\runpy.py", line 73, in _run_code
        exec(code, run_globals)
      File "e:\python-dev\py3k\lib\test\test_capi.py", line 182, in <module>
        test_main()
      File "e:\python-dev\py3k\lib\test\test_capi.py", line 143, in test_main
        support.run_unittest(CAPITest)
      File "e:\python-dev\py3k\lib\test\support.py", line 1127, in run_unittest
        _run_suite(suite)
      File "e:\python-dev\py3k\lib\test\support.py", line 1110, in _run_suite
        raise TestFailed(err)
    test.support.TestFailed: Traceback (most recent call last):
      File "e:\python-dev\py3k\lib\test\test_capi.py", line 50, in test_no_FatalErro
    r_infinite_loop
        b'Fatal Python error:'
    AssertionError: b'Fatal Python error: PyThreadState_Get: no current thread\r\n\r
    \nabnormal program termination' != b'Fatal Python error: PyThreadState_Get: no c
    urrent thread'

    This happens because "abnormal program termination" is output to
    stderr. Another capable sink to output error message into is
    messagebox, of cause it is not what we want. There is no way to
    silent this.

    I think there are a few options to take.

    • Skip this test on VC6 (And probably VS7.1)
    • Check not equality, but if stderr starts with "Fatal Python ...."

    @ocean-city ocean-city mannequin removed the release-blocker label Sep 9, 2010
    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Sep 9, 2010

    Here is the patch. On VS8.0 or above,

    • Avoid DebugBreak() call by IsDebuggerPresent().
    • Tell abort() not to print message to console or window.

    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Sep 10, 2010

    Maybe is bpo-5619 related?

    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Nov 14, 2010

    Hirokazu's patch works for me. Could this approach be taken in general to
    suppress all buildbot pop-ups?

    @briancurtin
    Copy link
    Member Author

    The patch works for me.
    Unfortunately my knowledge on this particular area is very low so I can't really evaluate the patch.

    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Dec 13, 2011

    I just tried out http://www.bitvise.com/winsshd , which is free for personal
    and noncommercial use. If you run the tests via an ssh connection, WinSSHD
    automatically translates pop-ups into error messages:

    C:\Users\stefan\cdecimal\PCbuild>python.exe -m test -uall test_capi
    [1/1] test_capi
    Warning -- threading._dangling was modified by test_capi
    test test_capi failed -- Traceback (most recent call last):
      File "C:\Users\stefan\cdecimal\lib\test\test_capi.py", line 51, in test_no_FatalError_infinite_loop
        b'Fatal Python error:'
    AssertionError: b"Fatal Python error: PyThreadState_Get: no current thread\n\r\nThis application has requested the Runtime to terminate it in an unusual way.\nPlease contact the application's support team for more information." != b'Fatal Python error: PyThreadState_Get: no current thread'

    1 test failed:
    test_capi

    Thus, by using ...

       self.assertIn(b'Fatal Python error:', err.rstrip())

    in test_capi, the tests pass without any further intervention! This is most
    interesting, to the point that I'm considering setting up a buildbot.

    @terryjreedy
    Copy link
    Member

    I just got 'fatal error' running python_d 3.3.a0 checked out yesterday. When I closed message, test continued (but really crashed later).

    @vsajip
    Copy link
    Member

    vsajip commented May 5, 2012

    The AssertionError in Brian's initial post indicates that the test is too restrictive. Though the discussion here has talked about removing the popups altogether, the test passes on Windows with a small change: instead of assertEqual(), I used

    self.assertTrue(err.rstrip().startswith(
                    b'Fatal Python error:'
                    b' PyThreadState_Get: no current thread'))
    

    Patch attached. As this seems to be a sufficiently specific test, but not too specific, I'd like to apply this patch soon, unless someone thinks the test needs to stay exactly like it is.

    @skrah
    Copy link
    Mannequin

    skrah mannequin commented May 5, 2012

    I tested the patch, it works fine. I can't test the popup situation
    since I currently only have ssh access.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 6, 2012

    New changeset 4d74d275224d by Vinay Sajip in branch 'default':
    Issue bpo-9116: Allowed test to pass on Windows by adjusting the test condition slightly to allow for a Windows-specific error message.
    http://hg.python.org/cpython/rev/4d74d275224d

    @ezio-melotti
    Copy link
    Member

    Vinay commit made the test pass, but the popup is still present.
    Removing the popup is discussed in bpo-11732.

    @zware
    Copy link
    Member

    zware commented Jul 3, 2014

    With the popup-supression context manager from bpo-11732 in use and the buildbots using the regrtest '-n' option, I think we're at the point of being "fixed enough" and vote to close this issue. I'll leave the final decision to someone with a deeper understanding of the issue, though.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @kumaraditya303
    Copy link
    Contributor

    Closing as it is "fixed enough", feel free to reopen if required.

    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) OS-windows tests Tests in the Lib/test dir type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    8 participants