Tk Source Code

View Ticket
Login
Ticket UUID: 2374c602bf4015a7a87445fb2b12b02f528a064e
Title: bind-34.1 sometimes fails on Linux
Type: Bug Version: core-8-6-branch
Submitter: fvogel Created on: 2021-03-09 21:42:09
Subsystem: 86. Test Tools Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2021-03-13 09:31:53
Resolution: Fixed Closed By: fvogel
    Closed on: 2021-03-13 09:31:53
Description:

bind-34.1 sometimes fails on Linux (race condition)

Once in 30 or 50 runs of the bind-34.* tests, bind-34.1 fails as follows:

==== bind-34.1 -warp works relatively to a window FAILED
==== Contents of test case:

    # In order to avoid platform-dependent coordinate results due to
    # decorations and borders, this test warps the pointer twice
    # relatively to a window that moved in the meantime, and checks
    # how much the pointer moved
    event generate .top <Motion> -x 20 -y 20 -warp 1
    update idletasks ; # DoWarp is an idle callback
    after 50         ; # Win specific - wait for SendInput to be executed
    set pointerPos1 [winfo pointerxy .top]
    wm geometry .top +600+600
    update
    event generate .top <Motion> -x 20 -y 20 -warp 1
    update idletasks ; # DoWarp is an idle callback
    after 50         ; # Win specific - wait for SendInput to be executed
    set pointerPos2 [winfo pointerxy .top]
    # from the first warped position to the second one, the mouse
    # pointer should have moved the same amount as the window moved
    set res 1
    foreach pos1 $pointerPos1 pos2 $pointerPos2 {
        if {$pos1 != [expr {$pos2 - 400}]} {
            set res [list $pointerPos1 $pointerPos2]
        }
    }
    set res

---- Result was:
{124 149} {624 649}
---- Result should have been (exact matching):
1
==== bind-34.1 FAILED

Observed on Linux Debian 10, but not on Windows or macOS.

User Comments: fvogel added on 2021-03-13 09:31:53:

1000 runs of bind-34.* and 100 runs of the full bind.test file does no longer produce a single failure. In contrast, at [0cb316cc] (the commit just before the fix [44d67f67]), 100 runs of bind.test produces 5 failures of bind-34.1.

I have therefore merged the fix.


fvogel added on 2021-03-09 22:02:56:

This is a race condition. 'wm geometry' runs UpdateGeometryInfo() as an idle callback, on all platforms.

Commit [44d67f67] gives a few ms to the OS to get that callback in the event loop before running the following 'update' that services it. Therefore, bind-34.1 should now always pass.