Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 90f76a2ac6143d7c20eeb6ac3b4ab9b16e8b408f28f8482e1b5b6e6269d66082
Ticket: 61c01e0edb08a9ed905aefdf17ce113da303c77b
likely race condition with package require in several threads causing error
User & Date: anonymous on 2025-07-18 04:25:47
Changes

  1. icomment:
    Good to hear the progress. For completeness, I did go ahead and instrument the pkgIndex file as such:
    
    if {![package vsatisfies [package provide Tcl] 8.5 9]} {return}
    proc _mysource {file} {
        set ::math_error "ok"
        if [catch {
            source $file
        } err] {
            set ::math_error $err
            return -code error $err
        }
    }
    package ifneeded math                    1.2.6 [list _mysource [file join $dir math.tcl]]
    incr ::in_pkgIndex_tcl
    ...
    
    In the failing thread, it simply never executes the source command, while in the threads that work, I see the ok value. I also modified the script to actually use a math function and tested for the value being correct:
    
    set script {
        if [catch {
            package require math
            set ::math_fib_result_55 [math::fibonacci 10] 
            if { $::math_fib_result_55 != 55} {
            	error "error with math::fibonacci, not 55, was $::math_fib_result_55"
            }
    
    
    And this would always, when it didn't fail on the package require, give the correct value of using the fibonacci function.
    
    Thanks for looking at this!
    
  2. login: "anonymous"
  3. mimetype: "text/plain"