Tcl package Thread source code

View Ticket
Login
Ticket UUID: 76f47e0376fb8b2783627799fd7f2adab66d98f9
Title: thread::send -async script varname aborts with "alloc: invalid block"
Type: Bug Version: all
Submitter: pooryorick Created on: 2018-07-17 06:15:10
Subsystem: 80. Thread Package Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2018-07-17 11:12:16
Resolution: Fixed Closed By: pooryorick
    Closed on: 2018-07-17 11:12:16
Description:

With a Tcl compiled with --enable-symbols , the script

package require Thread
set t1 [thread::create]
thread::send -async $t1 {lindex {}} [expr 0]

results in:

alloc: invalid block

This happens because threadSendFree obtains the length of a Tcl_Obj before the string representation for that object is generated, and a few lines later the string representation is generated.

User Comments: pooryorick added on 2018-07-17 11:12:16:

The fix by sebres is at [98170da1657fb2dc]


sebres added on 2018-07-17 10:34:38:

Thanks Nathan (pooryorick) for finding and minimalistic fix. I've amended with more extensive fix replacing strcpy with memcpy (additionally should avoid segfault by overwrite if string representation would be possibly broken, e. g. without NTS 0-byte) and extended the test-cases to cover exactly this issue.

So fixed now in 2.8 and trunk, thus close.