Overview
| Artifact ID: | 0bf23a6f00da92c750bd6824d3d1a9283dd0cce91c4145b1b7a9b11c476a8355 |
|---|---|
| Ticket: | 61c01e0edb08a9ed905aefdf17ce113da303c77b
likely race condition with package require in several threads causing error |
| User & Date: | anonymous on 2025-07-16 20:36:14 |
Changes
- icomment:
updated test scripts, failure in 9.02 also Here are a new batch script, that counts errors, and a new script that exits with a 0 or 1 depending on error status so the batch can be run for long periods. On an error, the dialog box, if "no" is clicked, will suspend, otherwise it will error exit in 10 seconds. bugx.bat: @echo off setlocal set "loopCounter=0" set "errorCounter=0" set "distro=%1" &REM Get the distro parameter if "%distro%"=="1" ( set "commandToRun=C:\\bawTcl\\bin\\wish90.exe A:\\bug.tcl" ) else if "%distro%"=="2" ( set "commandToRun=D:\\podcasts\\Tcl902\\bin\\wish90.exe A:\\bug.tcl" ) else if "%distro%"=="3" ( set "commandToRun=C:\\tclf\\kits\\mytcl901.exe A:\\bug.tcl" ) else if "%distro%"=="4" ( set "commandToRun=C:\\Users\\core5\\AppData\\Local\\Apps\\Tcl86\\bin\\wish.exe A:\\bug.tcl" ) else ( echo Invalid distro parameter. Please specify 1, 2, 3, or 4. exit /b 1 ) echo Command to run: %commandToRun% :loopStart echo Loop Counter: %loopCounter% ^| Error Counter: %errorCounter% %commandToRun% if errorlevel 1 ( rem echo Error detected! Exit code: %errorlevel% set /a errorCounter+=1 ) else ( rem echo Command completed successfully. ) rem timeout /t 1 >nul &REM Add a 1-second delay set /a loopCounter+=1 goto loopStart endlocal bug.tcl: console show wm withdraw . package require Thread package require math tsv::set tids [thread::id] mainthread ;# for reverse lookup tsv::set main mainthread [thread::id] ;# for reverse lookup ################################################# Tasks version 1.13h namespace eval tasks { proc wait { ms } { ;# non busy wait set uniq [incr ::__sleep__tmp__counter] set ::__sleep__tmp__$uniq 0 after $ms set ::__sleep__tmp__$uniq 1 vwait ::__sleep__tmp__$uniq unset ::__sleep__tmp__$uniq } ################################################# dump all task shared variables proc tdump {{pat .*} {max 90}} { ;# dump all the shared Task variables set all 1 set doputz 1 set out {} if { [string index $pat 0] eq "-" } { ;# a leading - reduces output to just the variables set all 0 set pat [string range $pat 1 end] } elseif { [string index $pat 0] eq "+" } { ;# a leading + no output puts either AND return results in $out set all 0 set doputz 0 set pat [string range $pat 1 end] } set tvarnames [lsort -stride 2 -index 1 [tsv::array get tids]] foreach {var val} [lsort -dictionary -stride 2 -index 1 $tvarnames ] { set tidnames [tsv::array names tvar $val,*] foreach tname [lsort $tidnames] { set value [tsv::get tvar $tname] # set value [string map {\n \u2936 \t \u02eb} $value] if { [regexp .*${pat}.* "$tname\t[string range $value 0 $max]"] } { if { $doputz } { puts " [format %-27s ($tname)] = |[string range $value 0 $max]| " } else { lappend out [list $tname $value] } } } } return $out ;# will be null unless +pat was used - to avoid dummping it all in interactive mode or windows console } #proc - main Task procs ----------------------------------------------------------- ################################################# proc Task {name args} { ;# create a Task set script { if [catch { package require math if [catch {while 1 { thread::wait }} thread_err_code thread_err_dict] { tsv::set tvar tasknamex,error $thread_err_dict catch {package require Tk}; package require Tk; wm withdraw . set zzz [tk_messageBox -type yesno -detail {Select yes to exit, no to suspend} -title {task error} \ -message "1: $thread_err_code\n\n$thread_err_dict\nauto_path in thread: [thread::id]\n[join [set auto_path] \n]" if {$zzz eq "yes"} exit else {thread::send maintid {after cancel $::exitafter} ; vwait ::forever1} } } err_code_Task_Create err_code_Task_Create_details] { tsv::set tvar tasknamex,error $err_code_Task_Create catch {package require Tk}; package require Tk; wm withdraw . set zzz [tk_messageBox -type yesno -detail {Select yes to exit, no to suspend} -title {Task create error} \ -message "2: $err_code_Task_Create \n$err_code_Task_Create_details\nauto_path in thread: [thread::id]\n[join [set auto_path] \n]"] if {$zzz eq "yes"} exit else {thread::send maintid {after cancel $::exitafter} ; vwait ::forever2} } } regsub -all tasknamex,error $script $name,error script;# substitute in the actual task name regsub -all maintid $script [thread::id] script ;# substitute in the actual thread id of main thread set tid [thread::create $script] tsv::set tvar $name,tid $tid tsv::set tvar $name,script $script tsv::set tids $tid $name ;# for reverse lookup return $tid } namespace export tdump } # end of tasks namespace eval puts "auto_path in main thread:\n[join [set auto_path] \n]" ;# dump this in main thread namespace import tasks::* update tasks::Task Taskname1 tasks::Task Taskname2 if { 1 } { ;# when 0, it does not fail on my systems # tasks::wait 10 ;# also sufficient to no longer fail tasks::Task Taskname3 } set ok 1 tasks::wait 100 tasks::tdump -,error|,tid foreach t [tasks::tdump +,error] { lassign $t a b; if {$b ne ""} {bell;set ok 0} } if { $ok } { wm withdraw . puts "*****ok******* [info nameof]\n[info patch]" after 250 {exit 0} } set ::exitafter [after 10000 {exit 1}] - login: "anonymous"
- mimetype: "text/plain"