Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 87c742143f3a9f19e384e0028b9c0e374a72034354eaa7306360bca4a97a8c5c
Ticket: 536ae0326dd09dc372d5e7ab9637384ed9221393
tsv::set or get in thread 2.8.8 crash
User & Date: anonymous on 2022-12-28 00:12:34
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    The below script crashes either of tclsh or wish. It's using Threads and tsv. It only seems to crash Thread 2.8.8 regardless of which of several versions of tcl I choose, on either windows or linux.
    
    Please adjust the auto_path settings below for your system and choose one of 7,8, or 0 to choose which version it will force package Thread to use. It should work ok on other than 2.8.8.
    
    I've tried 8.6.12, 8.6.13, and an 8.7a6 on windows, and 8.6.12 or 8.6.13 on linux, all 64 bit systems.
    
    This crash is occuring for me on both windows (silent crash, thinks for 5 seconds then dies) and linux, where I have built tcl/tk with debug symbols and get a segv running it against my build and with gdb.
    
    
    
    I believe the cause is a shimmering problem when using tsv::get (or set) on a tsv shared variable (foo bar) that it thinks is a list, and so has to convert. The crash occurs because the pointer objPtr->typePtr it's attempting to use is 0.
    
    I can't get the same info on windows, since I don't have a way to build tcl/tk with debugging. 
    
    In the below, I place it in file crash.tcl and source it.
    
    ----------------
    
        set use 8
        if { $use == 8 } {
            lappend auto_path {C:\Users\core5\AppData\Local\Apps\Tcl86\lib\thread2.8.8}
            set tver [package require -exact Thread 2.8.8]
        } elseif { $use == 7  } {
            lappend auto_path {C:\tclf\tclpkgs64}
            set tver [package require  -exact Thread 2.8.7]
        } else {
            lappend auto_path {C:\tclf\tclpkgs64}
            set tver [package require   Thread]
        }
        puts "tver= |$tver| tcl= [info pa]" 
        
        catch {console show}
        catch {wm withdraw .}
        update
        tsv::set foo bar {}
        
        tsv::lpush      foo    bar {a b c} end
        tsv::lpush      foo    bar {d e f} end
        set len [tsv::llength foo bar]
        puts "len= |$len| "
        set zzz2 [tsv::lpop foo bar]
        puts "zzz2= |$zzz2| "
        
        set script {
            set ret [tsv::get foo bar]
        }
        set tid [thread::create]
        puts "tid= |$tid| "
        
        set zzza [thread::send $tid $script]
        puts "zzza= |$zzza| "
        
        set script2 {
            set ret [tsv::lpop foo bar]
        }
        set script3 {
            set ret [tsv::llength foo bar]
        }
        set script4 {
            set ret [tsv::set foo bar]
        }
        set script5 {
            set ret [tsv::get foo bar]
        }
        foreach item {1 2} {
            tsv::lpush      foo    bar [list a b $item 1] end
            tsv::lpush      foo    bar [list a b $item 2] end
            
            set zzz2 [thread::send $tid $script2] ;# pop
            puts "zzz2= |$zzz2| "
            
            set zzz3 [thread::send $tid $script3] ;# len
            puts "zzz3= |$zzz3| "
            
            set zzz4 [thread::send $tid $script4] ;# set
            puts "zzz4= |$zzz4| "
            
            set zzz5 [thread::send $tid $script5] ;# get
            puts "zzz5= |$zzz5| "
            
        }
        set tid [thread::id]
        foreach item {1 2 3} {
            
            set zzz2 [thread::send $tid $script2] ;# pop
            puts "zzz2= |$zzz2| "
            
            set zzz3 [thread::send $tid $script3] ;# len
            puts "zzz3= |$zzz3| "
            
            set zzz4 [thread::send $tid $script4] ;# set
            puts "zzz4= |$zzz4| "
            
            set zzz5 [thread::send $tid $script5] ;# get
            puts "zzz5= |$zzz5| "
            update
        }
        puts "ok"
        update
    
    
    
    
    
    
    
    [2496]$ LD_LIBRARY_PATH=/home/et/vwtests/mytcltk/build13/lib gdb /home/et/vwtests/mytcltk/build13/bin/wish8.6
    Reading symbols from /home/et/vwtests/mytcltk/build13/bin/wish8.6...
    (gdb) r
    Starting program: /home/et/vwtests/mytcltk/build13/bin/wish8.6 
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    % [New Thread 0x7ffff5bae700 (LWP 4705)]
    
    % 
    % source crash.tcl
    tver= |2.8.8| tcl= 8.6.13
    len= |2| 
    zzz2= |a b c| 
    [New Thread 0x7ffff538e700 (LWP 4707)]
    tid= |tid0x7ffff538e700| 
    zzza= |{d e f}| 
    zzz2= |d e f| 
    zzz3= |2| 
    zzz4= |{a b 1 1} {a b 1 2}| 
    zzz5= |{a b 1 1} {a b 1 2}| 
    zzz2= |a b 1 1| 
    zzz3= |3| 
    zzz4= |{a b 1 2} {a b 2 1} {a b 2 2}| 
    zzz5= |{a b 1 2} {a b 2 1} {a b 2 2}| 
    zzz2= |a b 1 2| 
    zzz3= |2| 
    zzz4= |{a b 2 1} {a b 2 2}| 
    zzz5= |{a b 2 1} {a b 2 2}| 
    zzz2= |a b 2 1| 
    zzz3= |1| 
    zzz4= |{a b 2 2}| 
    zzz5= |{a b 2 2}| 
    zzz2= |a b 2 2| 
    zzz3= |0| 
    
    Thread 1 "wish8.6" received signal SIGSEGV, Segmentation fault.
    Tcl_GetString (objPtr=0x55555587cab0) at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclObj.c:1642
    1642	    if (objPtr->typePtr->updateStringProc == NULL) {
    
    (gdb) backtrace 
    #0  Tcl_GetString (objPtr=0x55555587cab0) at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclObj.c:1642
    #1  0x00007ffff7d2b54b in Tcl_GetStringFromObj (objPtr=0x55555587cab0, lengthPtr=0x7fffffffd1f0) at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclObj.c:1692
    #2  0x00007ffff7ccd723 in TEBCresume (data=0x5555556479a8, interp=0x555555570070, result=0) at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclExecute.c:2776
    #3  0x00007ffff7bee822 in TclNRRunCallbacks (interp=0x555555570070, result=0, rootPtr=0x0) at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclBasic.c:4503
    #4  0x00007ffff7bf1616 in TclEvalObjEx (interp=0x555555570070, objPtr=0x5555555b59e0, flags=131072, invoker=0x0, word=0)
        at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclBasic.c:6068
    #5  0x00007ffff7bf15aa in Tcl_EvalObjEx (interp=0x555555570070, objPtr=0x5555555b59e0, flags=131072) at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclBasic.c:6049
    #6  0x00007ffff7cee179 in Tcl_RecordAndEvalObj (interp=0x555555570070, cmdPtr=0x5555555b59e0, flags=131072)
        at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclHistory.c:190
    #7  0x00007ffff7cedde7 in Tcl_RecordAndEval (interp=0x555555570070, cmd=0x7fffffffdcf0 "source crash.tcl\n", flags=131072)
        at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclHistory.c:75
    #8  0x00007ffff7e63488 in StdinProc (clientData=0x7fffffffdcd0, mask=2) at /home/et/vwtests/mytcltk/tk8.6.13/unix/../generic/tkMain.c:443
    #9  0x00007ffff7d0283b in Tcl_NotifyChannel (channel=0x55555566d9f0, mask=2) at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclIO.c:8425
    #10 0x00007ffff7d84ba1 in FileHandlerEventProc (evPtr=0x5555556636c0, flags=-3) at /home/et/vwtests/mytcltk/tcl8.6.13/unix/tclUnixNotfy.c:808
    #11 0x00007ffff7d2a046 in Tcl_ServiceEvent (flags=-3) at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclNotify.c:670
    #12 0x00007ffff7d2a486 in Tcl_DoOneEvent (flags=-3) at /home/et/vwtests/mytcltk/tcl8.6.13/generic/tclNotify.c:967
    #13 0x00007ffff7e4cbf5 in Tk_MainLoop () at /home/et/vwtests/mytcltk/tk8.6.13/unix/../generic/tkEvent.c:2109
    #14 0x00007ffff7e63252 in Tk_MainEx (argc=-1, argv=0x7fffffffdfd0, appInitProc=0x5555555551da <Tcl_AppInit>, interp=0x555555570070)
        at /home/et/vwtests/mytcltk/tk8.6.13/unix/../generic/tkMain.c:376
    #15 0x00005555555551d3 in main (argc=1, argv=0x7fffffffdfc8) at /home/et/vwtests/mytcltk/tk8.6.13/unix/../unix/tkAppInit.c:93
    
    (gdb) print objPtr
    $1 = (Tcl_Obj *) 0x55555587cab0
    
    (gdb) print *objPtr
    $2 = {refCount = 3, bytes = 0x0, length = 0, typePtr = 0x0, internalRep = {longValue = 93824995542336, doubleValue = 4.6355707018676314e-310, 
        otherValuePtr = 0x55555587c540, wideValue = 93824995542336, twoPtrValue = {ptr1 = 0x55555587c540, ptr2 = 0x55555587cae0}, ptrAndLongRep = {ptr = 0x55555587c540, 
          value = 93824995543776}}}
    
  5. foundin changed to: "severl tcl thread 2.8.8"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "d56951567818168a378b74742413a04b69fa8aca"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "anonymous"
  14. subsystem changed to: "80. Thread Package"
  15. title changed to: "tsv::set or get in thread 2.8.8 crash"
  16. type changed to: "Bug"