Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-13
11:18 • Ticket [699739ffff] app can overrun console buffer on Windows status still O... artifact: 57c45fb4fe user: serhiy.storchaka
2007-11-16
05:32 • Open ticket [699739ffff]. artifact: a8874189bb user: dkf
05:32 • Ticket [699739ffff]: 6 changes artifact: d14b53d293 user: dkf
00:16 • Closed ticket [699739ffff]. artifact: 5a2ff48c70 user: davygrvy
2007-02-27
02:49 • Ticket [699739ffff]: 1 change artifact: 7ff320becb user: kennykb
2005-11-04
04:56 • Ticket [699739ffff]: 1 change artifact: b4edf9a76b user: davygrvy
2004-06-03
02:24 • Ticket [699739ffff]: 4 changes artifact: aaae816afd user: davygrvy
2004-06-01
16:50 • Ticket [699739ffff]: 4 changes artifact: 9d856db9b3 user: davygrvy
2003-04-23
03:30 • Ticket [699739ffff]: 1 change artifact: 3a7ae4db03 user: davygrvy
2003-03-08
00:42 • New ticket [699739ffff]. artifact: 1b53afc25f user: kennykb

app can overrun console buffer on Windows

Open699739ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 19 days ago
Descriptionplain2003-03-08 00:42:15
If an application configures a very large buffer on stdout, and then writes
a large amount of data to the console on Windows, the write fails with

error writing "stdout": not enough memory

A script that illustrates the problem is:

fconfigure stdout -buffering full -buffersize 262144
for { set i 0 } { $i <= 10000 } { incr i } {
    puts ----------------------------------------------------------------------
}

It's reasonable for the write to block, but this failure is bizarre.
davygrvy Ticket [699739ffff]: 1 change [History diff]2003-04-23 03:30:39
davygrvyplain2004-06-01 16:50:52
Logged In: YES 
user_id=7549

Just put tcl in the debugger to look at this.

WriteFile itself is failing in ConsoleOutputProc().  I think the 
summary of this problem is that the other end can't accept a 
buffer this big and rather than soaking up some of it, it just 
barfs.

I don't know if there is an easy way to fix this.  Even if we 
knew the limit ahead of time (maybe GetConsoleBufferInfo 
could get us the answer?) we have no way for the driver to 
intercept a setting of the buffersize from the driver side.
davygrvyplain2004-06-03 02:24:20
Logged In: YES 
user_id=7549

It seems the upper limit -buffersize is 0x7FFF.  One over that 
and WriteFile fails with ENOMEM.

I can't think of a way to fix this aside from adding a way for 
drivers to intercept requests to change the buffersize.
davygrvy Ticket [699739ffff]: 1 change [History diff]2005-11-04 04:56:04
kennykb Ticket [699739ffff]: 1 change [History diff]2007-02-27 02:49:18
davygrvyplain2007-11-16 00:16:51
Logged In: YES 
user_id=7549
Originator: NO

I don't believe a fix for this is possible given there are no hooks available to a channel driver to restrict the generic side's standard fconfigure settings.  I've come across this before.  Also in the Console channel driver changing -encoding to something other than unicode when running on NT causes big problems.

Could this become a new TIP?  a new hook such that generic layer setting requests are forwarded to the driver for validation before accepted?
dkfplain2007-11-16 05:32:26
data_type - 360894
dkf Open ticket [699739ffff]. [History diff]2007-11-16 05:32:50
serhiy.storchaka Ticket [699739ffff]: 2 changes [History diff]2026-11-13 11:18:46
Log in (anonymous is fine) to add a comment.