Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-07-19
00:29 • Ticket [427196ffff] fconfigure -buffer in midread =>segfault status still... artifact: 6a3f158667 user: andreas_kupries
2001-07-18
04:11 • Add attachment tcl.427196.2.diff.txt to ticket [427196ffffffffff|427196... artifact: cc0c1d59e9 user: andreas_kupries
04:11 • Ticket [427196ffff] fconfigure -buffer in midread =>segfault status still... artifact: c285c563e2 user: andreas_kupries
01:45 • Add attachment tcl.427196.1.diff.txt to ticket [427196ffffffffff|427196... artifact: 4d6437dda8 user: andreas_kupries
01:45 • Ticket [427196ffff] fconfigure -buffer in midread =>segfault status still... artifact: 6b2dbefba8 user: andreas_kupries
01:45 • Ticket [427196ffff]: 2 changes artifact: 5ecddd80de user: andreas_kupries
00:54 • Closed ticket [427196ffff]. artifact: 32610a53e1 user: andreas_kupries
00:47 • Add attachment tcl.427196.0.diff.txt to ticket [427196ffffffffff|427196... artifact: f9f99ef42a user: andreas_kupries
00:47 • Ticket [427196ffff] fconfigure -buffer in midread =>segfault status still... artifact: d20ce36b4e user: andreas_kupries
00:10 • Ticket [427196ffff]: 6 changes artifact: 29ee7f1342 user: andreas_kupries
2001-05-25
13:32 • Add attachment buffer.tcl to ticket [427196ffff] artifact: e3e53e6387 user: dgp
13:32 • Ticket [427196ffff] fconfigure -buffer in midread =>segfault status still... artifact: 59f87546a6 user: dgp
06:32 • New ticket [427196ffff]. artifact: 305daba531 user: dgp

fconfigure -buffer in midread =>segfault

Closed / Fixed427196ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 25 years ago
Descriptionplain2001-05-25 06:32:50
 The demo script reads part of a file, then changes
the buffer size, then tries to read the rest of the
file.  Then, either a segfault or a POSIX error.

To diagnose the memory problem, evaluate the demo
script in a tclsh built with TCL_MEM_DEBUG:

$ ./tclsh buffer.tcl 
hi guard byte 0 is 0x65         e
hi guard byte 2 is 0x64         d
hi guard byte 3 is 0x20          
hi guard byte 4 is 0x24         $
hi guard byte 5 is 0x63         c
total mallocs                   1402
total frees                      791
current packets allocated        611
current bytes allocated        49654
maximum packets allocated        759
maximum bytes allocated        87378
high guard failed at 80d9008, ./../generic/tclIO.c 4913
58 bytes allocated at (./../generic/tclIO.c 1659)
Memory validation failure
Aborted (core dumped)

Apparently this problem first appeared in Tcl 8.1.
dgpplain2001-05-25 13:32:50
File Added - 6648: buffer.tcl
andreas_kupriesplain2001-07-18 00:10:07
Logged In: YES 
user_id=75003

The reason for the crash is a combination of two things: 
First, the buffer allocated when -buffersize 10 was set is 
reused in the second read. And second, the IO system 
blithely uses the set buffersize as the number of bytes to 
read and not the actual size of the buffer in use. This 
causes the overwrite beyond the end of the buffer and the 
subsequent crash when closing the channel.

The relevant location is tclIO.c, line 5004 in "GetInput".

A patch will follow shortly.
andreas_kupriesplain2001-07-18 00:47:54
File Added - 8523: tcl.427196.0.diff.txt
andreas_kupries Closed ticket [427196ffff]. [History diff]2001-07-18 00:54:25
andreas_kupries Ticket [427196ffff]: 2 changes [History diff]2001-07-18 01:45:01
andreas_kupriesplain2001-07-18 01:45:02
File Added - 8526: tcl.427196.1.diff.txt
andreas_kupriesplain2001-07-18 04:11:23
File Added - 8533: tcl.427196.2.diff.txt

Logged In: YES 
user_id=75003

Upload of patch which squashes the performance problem
for dynamically changing buffersizes, by squashing buffers
which are to small.
andreas_kupriesplain2001-07-19 00:29:34
Logged In: YES 
user_id=75003

Performance patch committed to main and core-8-3-1-branch.
This item is now completely closed.
Log in (anonymous is fine) to add a comment.

Attachments: