Tcl Source Code

View Ticket
Login
Ticket UUID: 17902c18822fc2f14d9ab7c8fc2be704bb5631b
Title: env(PATHEXT) not present
Type: Bug Created on: 2017-11-01 18:50:21
Submitter: anonymous Assigned to: nobody
Subsystem: 08. Environment Variables Severity: Cosmetic
Priority: 5 Medium Last modified: 2026-10-21 10:03:36
Status: Closed Closed by: nobody
Resolution: Fixed Closed on: 2017-11-03 07:16:45
Version: 8.6.7
Description:
https://www.androwish.org/index.html/fdiff?v1=50e9b426df9f2e14&v2=0ca5e5078019f13a&sbs=1
uses "array exist env" to force population of the internal representation
of the env stuff for the case that existence of env(PATHEXT) is not initially
known per "info exist". Otherwise an internal read trace may cause the "info
exist" to fail. This was observed on ReactOS.

PS: Not that ReactOS is in any sense a reference but still the only independent
implementation of a Windows like OS, and thus IMO worthwhile a platform for tests.
User Comments:
sebres added on 2017-11-02 12:05:21:

> Otherwise an internal read trace may cause the "info exist" to fail. This was observed on ReactOS.
Can you provide more info here (actual error, call stack, etc.). Because "internal read trace" (to read env-array) looks safe here (for single element as well as on read the whole array).

Also if PATHEXT don't set on ReactOS environment, it should nevertheless work. I know currently only one usage of it in the tcl-library (in init.tcl):

proc auto_execok name {
    ...
    if {[info exists env(PATHEXT)]} {
	# Add an initial ; to have the {} extension check first.
	set execExtensions [split ";$env(PATHEXT)" ";"]
    } else {
	set execExtensions [list {} .com .exe .bat .cmd]
    }
Which looks pretty safe...


anonymous added on 2017-11-02 19:51:08:
While trying to reproduce it today I failed miserably.
No idea what went really wrong. Sorry for the noise. Please close the ticket.

anonymous added on 2017-11-03 07:16:45:
Sorry, more noise follows. I believe now that I understand the problem.

ReactOS uses creative syntax for PATH and COMSPEC ("Path" and "ComSpec").
There are two brains in the Tcl core dealing with the environment using
traces, library/init.tcl with element traces on PATH/COMSPEC and creative
written versions, and generic/tclEnv.c with a whole array trace syncing the
environ[] C library array to the env Tcl array.

There might be circumstances where the two logics badly interact with each
other. Thus I've removed the library/init.tcl logic to solely deal with
upper casing the PATH and COMSPEC entries in generic/tclEnv.c as can be
seen in this check-in:

  https://www.androwish.org/index.html/info/2f649dbd33a6f249

serhiy.storchaka added on 2026-10-21 10:03:36:

The approach suggested here, upper-casing PATH and COMSPEC in tclEnv.c, has been in Tcl since 8.6.10 ([e8d0d31e48], ticket [9471e6e304]), and Tcl 9 no longer has the init.tcl env traces. The reporter could not reproduce the original problem, so closing.