Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 8a5f358fa778bb17aea8f601660cb7f980c62f35586bd0527fd06e553506291f
Ticket: 61c01e0edb08a9ed905aefdf17ce113da303c77b
likely race condition with package require in several threads causing error
User & Date: anonymous on 2025-07-17 19:33:38
Changes

  1. icomment:
    The magicsplat distro doesn't use the //zipfs and it can also fail.
    
    Note: I can get the failure with other packages, not just math. I tried to see if the other packages with errors had something in common with the math package, but was unable to find a correlation. I am just using package math in my posted code since that seems to fail more often.
    
    If I change the code to do,
    
    catch {package require math}
    catch {package require math}
    catch {package require math}
    package require math
    
    then the error rate is lowered, but if I increase the number of threads, from say 3, to 25, the error rate is increased.
    
    The access violation only happens with the tclkit from bawt. Since I don't build that, I don't know how to get symbols for it. What I do see is by using visual studio 2022 to inspect the crash dump file that windows creates.
    
    In order to output a tk messagebox, I also do a package require Tk (after an error on package math), and on occasion in the tclkit version, this would get an error saying something like, permission error. I attribute that to some sort of timing where in a tclkit, the tk dll has to be written out to the temp directory, and is possibly not fully written (or closed) by one thread, while the other thread is trying to do the same thing. To mitigate that, so I can get the message out, I do the same thing,
    
    catch {package require Tk); package require Tk
    
    Since it mostly works, it seems unlikely that the file encoding is an issue. The file math.tcl is on disk .../lib/tcllib2.0/math.tcl with the magicsplat distro, and my text editor says it is windows 1252 encoding; it can tell me if it is BOM encoding and also if there were any characters that are not standard ascii.
    
    The reason I use magicsplat and bawt is that I don't know how to get all the packages on a self built tcl/tk from source on linux. There I have in the past built tcl/tk with symbols and run using gdb.
    
    In my test code, I do a package require math at the top of the main script thinking if it was loaded there, it might then work inside the threads, but that didn't stop the failures.
    
  2. login: "anonymous"
  3. mimetype: "text/plain"