git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: gitk: race condition when changing view

From
Johannes Sixt <j6t@kdbg.org>
Date
Apr 18, 2026, 17:48 UTC
Message-ID
<ee2599a5-13b6-469a-a284-4a5d26b2c721@kdbg.org>
In-Reply-To
<20260416233639.32e5b481@rosa.suljee.de>
Am 16.04.26 um 23:36 schrieb Michael Warmuth-Uhl:
Show 52 quoted lines
> when displaying a bigger commit and then changing the view, gitk reports 
> 
>         can't read "treediffs(b107a60c5bed3002ecef93b4405a44d809776e6f)": no such variable
>         can't read "treediffs(b107a60c5bed3002ecef93b4405a44d809776e6f)": no such variable
>             while executing
>         "lsearch -exact $treediffs($ids) $fname"
>             (procedure "makediffhdr" line 7)
>             invoked from within
>         "makediffhdr $fname $ids"
>             (procedure "parseblobdiffline" line 56)
>             invoked from within
>         "parseblobdiffline $ids $line"
>             (procedure "getblobdiffline" line 16)
>             invoked from within
>         "getblobdiffline file6 b107a60c5bed3002ecef93b4405a44d809776e6f"
>             ("eval" body line 1)
>             invoked from within
>         "eval $script"
>             (procedure "dorunq" line 11)
>             invoked from within
>         "dorunq"
>             ("after" script)
> 
> It is reproducible with:
> 
>         TCDIR=/tmp/testcase
>         N=512
> 
>         rm -rf $TCDIR
>         git init $TCDIR
>         for i in `seq $N` ; do 
>             dd if=/dev/random status=none bs=1024 count=16 | uuencode "" > $TCDIR/foo_$i 
>         done
>         git -C $TCDIR add . 
>         git -C $TCDIR commit -m "commit" 
> 
>         cd $TCDIR
>         gitk --all
> 
> followed by an immediate change to "All Files" in gitk menu "View".
> 
> That happens because proc showview (and some others) clear treediffs which is 
> still needed by tasks pending in runq.
> 
> The patch below makes showview wait until runq is empty which is slow (waits for 
> useless operations) and feels wrong. I have no idea how to cleanly flush runq 
> instead.
> 
> The same issue has been mentioned here before: 
> 	https://stackoverflow.com/questions/17977996/gitk-cant-read-treediffs-error
> 
> Michael
Thank you for the report, the reproducer, and for digging into the issue.

Waiting for the process to complete is certainly not the most desirable way to handle the situation. I've attempted to clear the run queue with the patch below, but the reproduction recipe still triggers an error 'can't unset "currunq": no such variable', the reason being that proc dorunq is entered recursively via one of the queued scripts, and I haven't found why that is the case.

I'll look into this further as time permits, but don't hold your breath.
-- Hannes
diff --git a/gitk b/gitk
index dc042a5..51d9fe5 100755
--- a/gitk
+++ b/gitk
@@ -4693,6 +4693,17 @@ proc showview {n} {
     }
     unselectline
     normalline
+    global runq
+    foreach curq $runq {
+        set fd [lindex $curq 0]
+        if {$fd ne {}} {
+            catch {close $fd}
+        } else {
+            set script [lindex $curq 1]
+            unset isonrunq($script)
+        }
+    }
+    set runq {}
     unset -nocomplain treediffs
     clear_display
     if {[info exists hlview] && $hlview == $n} {
Previous: Michael Warmuth-Uhl
Message 2 of 2 in “gitk: race condition when changing view”
  1. Michael Warmuth-UhlApr 16, 2026
  2. Johannes SixtApr 18, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.