Ticket UUID: | 491341 | |||
Title: | GetsObj: trunc/append confusion @EOF | |||
Type: | Bug | Version: | obsolete: 8.4a4 | |
Submitter: | dgp | Created on: | 2001-12-10 22:31:37 | |
Subsystem: | 25. Channel System | Assigned To: | andreas_kupries | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2001-12-13 05:33:05 | |
Resolution: | Fixed | Closed By: | andreas_kupries | |
Closed on: | 2001-12-12 22:33:05 | |||
Description: |
When Tcl_GetsObj(chan, obj) receives an obj that already has a non-empty string rep, the bytes read from chan are supposed to be appended to the existing string rep. It is incorrect to assume that obj->bytes is an empty string. Tcl_GetsObj() gets this right almost everywhere, but this part of the spec was forgotten in lines 3634-3644 of tclIO.c, where EOF handling takes place. Those lines only work if obj->bytes passed in is an empty string. Since [gets] always does pass in such an empty Tcl_Obj, this bug isn't visible at the script level, but it shows up regularly in the call at line 300 of tclMain.c. Lines 304-306 of tclMain.c even appear to be an awkward attempt to work around this bug, without ever identifying it as a bug. To demo the bug, create a file test.tcl with a single line: if 1 { Then at a shell prompt $ tclsh < test.tcl This will stick tclsh in an infinite loop. Attached is the simple patch that correctly tests for "no characters read @ EOF" when obj-> bytes is non-empty. | |||
User Comments: |
andreas_kupries added on 2001-12-13 05:33:05:
Logged In: YES user_id=75003 Committed to head. andreas_kupries added on 2001-12-13 05:29:37: Logged In: YES user_id=75003 Confirmed passing of all tests for linux. dgp added on 2001-12-13 05:03:40: File Deleted - 14473: File Added - 14587: getsobj.patch dgp added on 2001-12-13 05:03:39: Logged In: YES user_id=80530 Here's the corrected patch. Passes all tests. andreas_kupries added on 2001-12-11 08:56:03: Logged In: YES user_id=75003 Sorry, but I cannot accept the patch yet. Here is the list of tests that fail for me (configure --disable-shared, linux 2.2.19, glibc 2.1.3) after applying the patch (I removed all failing tests which failed without the patch applied): compile-13.1 testing underestimate of maxStackSize in list cmd FAILED exec-16.2 flush output before exec FAILED io-6.12 Tcl_GetsObj: lf mode: lone \r FAILED io-6.13 Tcl_GetsObj: lf mode: 1 char FAILED io-6.15 Tcl_GetsObj: lf mode: several chars FAILED io-6.17 Tcl_GetsObj: cr mode: lone \n FAILED io-6.19 Tcl_GetsObj: cr mode: 1 char FAILED io-6.21 Tcl_GetsObj: cr mode: several chars FAILED io-6.23 Tcl_GetsObj: crlf mode: lone \n FAILED io-6.25 Tcl_GetsObj: crlf mode: \r\r FAILED io-6.27 Tcl_GetsObj: crlf mode: 1 char FAILED io-6.29 Tcl_GetsObj: crlf mode: several chars FAILED io-6.40 Tcl_GetsObj: auto mode: 1 char FAILED io-6.42 Tcl_GetsObj: auto mode: several chars FAILED io-6.43 Tcl_GetsObj: input saw cr FAILED io-6.44 Tcl_GetsObj: input saw cr, not followed by cr FAILED io-6.49 Tcl_GetsObj: auto mode: \r followed by \n FAILED io-6.50 Tcl_GetsObj: auto mode: \r not followed by \n FAILED io-6.51 Tcl_GetsObj: auto mode: \n FAILED io-6.54 Tcl_GetsObj: device EOF FAILED io-30.21 Tcl_Write, ^Z in middle ignored, Tcl_Read cr FAILED io-30.22 Tcl_Write, ^Z in middle ignored, Tcl_Read crlf FAILED io-31.5 Tcl_Write lf, Tcl_Gets cr FAILED io-31.6 Tcl_Write lf, Tcl_Gets crlf FAILED io-31.8 Tcl_Write cr, Tcl_Gets lf FAILED io-33.6 Tcl_Gets and end of file FAILED dgp added on 2001-12-11 05:31:38: File Added - 14473: getsobj.patch |
Attachments:
- getsobj.patch [download] added by dgp on 2001-12-13 05:03:39. [details]