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: |
(text/x-fossil-wiki)
With a Tcl compiled with <code>--enable-symbols</code> , the script <code><verbatim> package require Thread set t1 [thread::create] thread::send -async $t1 {lindex {}} [expr 0] </verbatim></code> results in: <code><verbatim> alloc: invalid block </verbatim></code> This happens because <code>threadSendFree</code> [https://core.tcl.tk/thread/artifact?udc=1&ln=992&name=27b80f574a4ced5a| obtains the length] of a <code>Tcl_Obj</code> before the string representation for that object is generated, and a few lines later [https://core.tcl.tk/thread/artifact?udc=1&ln=1014&name=27b80f574a4ced5a|the string representation is generated]. | |||
User Comments: |
pooryorick added on 2018-07-17 11:12:16:
(text/x-fossil-wiki)
The fix by sebres is at [98170da1657fb2dc] sebres added on 2018-07-17 10:34:38: (text/x-fossil-wiki) 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. |
![](http://core.tcl.tk/images/ext.png)