|
2020-08-12
| ||
| 11:39 | • Ticket [e87000d842] crash for "fconfigure stdout" in Win32 status ... artifact: 8ee28d9cc1 user: chw | |
| 10:32 | • Ticket [e87000d842]: 5 changes artifact: 42e47c868a user: jan.nijtmans | |
| 10:30 | Merge 8.6. Better solution for [e87000d842] check-in: eab09ae8ff user: jan.nijtmans tags: core-8-branch | |
| 10:25 | Fix [e87000d8425ab86a]: crash for "fconfigure stdout" in Win32. Even though the crash cannot happen ... check-in: 3d96bfb13f user: jan.nijtmans tags: core-8-6-branch | |
| 09:03 | • Ticket [e87000d842] crash for "fconfigure stdout" in Win32 status ... artifact: 87ca7bdc07 user: chw | |
| 07:06 | • Closed ticket [e87000d842]. artifact: 2f3b96090b user: jan.nijtmans | |
|
2020-08-11
| ||
| 13:31 | Fix [e87000d842]: crash for "fconfigure stdout" in Win32 check-in: b83d474338 user: jan.nijtmans tags: core-8-branch | |
| 11:58 | • Ticket [e87000d842] crash for "fconfigure stdout" in Win32 status ... artifact: 3556988b85 user: jan.nijtmans | |
| 11:41 | • New ticket [e87000d842]. artifact: 7ae66c3258 user: chw | |
crash for "fconfigure stdout" in Win32
Closed / Fixede87000d8425ab86af682dd8195b9d20826974ba8Created 6 years agoUpdated 6 years ago
Descriptionplain2020-08-11 11:41:36
When doing a "fconfigure stdout" or "chan configure stdout" on Win32
console channels, an immediate crash can happen. A potential fix is:
---8><------8><------8><------8><------8><------8><------8><------
Index: win/tclWinConsole.c
==================================================================
--- win/tclWinConsole.c
+++ win/tclWinConsole.c
@@ -1637,19 +1637,23 @@
}
if (valid) {
return TCL_OK;
}
- if (infoPtr->flags & CONSOLE_READ_OPS) {
- return Tcl_BadChannelOption(interp, optionName, "inputmode winsize");
- } else {
- return Tcl_BadChannelOption(interp, optionName, "");
+ if (len > 0) {
+ const char *optionList = "";
+
+ if (infoPtr->flags & CONSOLE_READ_OPS) {
+ optionList = "inputmode winsize";
+ }
+ return Tcl_BadChannelOption(interp, optionName, optionList);
}
+ return TCL_OK;
}
^L
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
---8><------8><------8><------8><------8><------8><------8><------
Referenced by2
eab09ae8ffMerge 8.6. Better solution for [e87000d842] check-in2020-08-12 10:30:14b83d474338Fix [e87000d842]: crash for "fconfigure stdout" in Win32 check-in2020-08-11 13:31:52
jan.nijtmans Ticket [e87000d842]: 3 changes
[History diff]2020-08-11 11:58:21
jan.nijtmansplain2020-08-12 07:06:26
Fixed now in core-8-branch. (btw. "winsize" is an androwish extension). Thanks!
chwplain2020-08-12 09:03:16
No, it is defined per tip#160 as can be seen in this check-in in core-8-branch: https://core.tcl-lang.org/tcl/blame?filename=win/tclWinConsole.c&checkin=42f24469aa
jan.nijtmanswiki2020-08-12 10:32:46
>No, it is defined per tip#160
Indeed, which means that my fix was wrong (applied to the wrong lines in tclWinConsole.c. The actual problem was in Tcl\_BadChannelOption() which didn't protect against NULL argument. Should be fixed better now.
-winsize is a read-only option, that's what caused the confusion.
Thanks!
chwplain2020-08-12 11:39:27
I think the problem is somewhat different. In the Win32 console case it starts with the (wrong) assumption, that the window size can be determined on stdin (the input handle from GetStandardHandle(...)). However, that information can only be read out from a console handle with a screen buffer, i.e stdout if obtained from GetStandardHandle(). A proof of concept which properly supports -winsize is in the AndroWish repo, see https://www.androwish.org/home/file?name=jni/tcl/win/tclWinConsole.c&ci=tip Regarding the crash: if you look at the various implementations of GetOptionsProc() most set a valid flag even in the optionName = NULL case and return earlier than Tcl_BadChannelOption(). Others deal with len > 0 (in case optionName is NULL, len is 0) and if len is zero don't call Tcl_BadChannelOption() at all.
Log in (anonymous is fine) to add a comment.