Tcl Source Code

View Ticket
Login
Ticket UUID: 422b0414a390567aa0f5070bced52d75aaa4fc02
Title: Tclsh91.exe from release 9.1.a1 crashes upon launch on older MS Windows release.
Type: Bug Created on: 2026-03-14 11:39:48
Submitter: erikleunissen Assigned to: apnadkarni
Subsystem: 69. Other Severity: Severe
Priority: 5 Medium Last modified: 2026-03-17 12:18:03
Status: Closed Closed by: jan.nijtmans
Resolution: Fixed Closed on: 2026-03-17 12:18:03
Version: 9.1a1
Description:
I know, Windows 7 isn't supported anymore.

However, shouldn't Tclsh (and Wish), bail out more gracefully than encountering
a "Fatal Error" upon launch under older OS's?

Here is my observation:
* As the very first thing after launch in Windows 7, a window pops up with title
  "Fatal Error", displaying the error message: "PGV Initializer did not initialize".
  See also the attached screenshot.
* When clicking the popup window away, the appended stack trace appears.

Notes:
* Tclsh was cross-built from linux using: x86_64-w64-mingw32-gcc (SUSE Linux) 9.2.0
* The segfault has not been observed:
  - with tclsh91 from release 9.1a0 (under MS Windows 7, built with the same
    cross toolchain).
  - when launching under MS Windows 11

-- stack trace (Dr. Mingw) --
tclsh91.exe caused an Illegal Instruction at location 000000006E8CA302 in module tcl91.dll.

AddrPC           Params
000000006E8CA302 004C004400540000 0000000000000000 000000000022EF50  tcl91.dll!Tcl_Panic+0x82
000000006E8FB4E6 000000000048FF30 0000000000000030 0000000000000000  tcl91.dll!TclGetProcessGlobalValue+0x266
000000006E922148 0044004300420041 0048004700460045 004C004B004A0049  tcl91.dll!TclpInitLibraryPath+0x78
000000006E8FB4BB 00000000003426A0 000000006E92F128 00000000003445D0  tcl91.dll!TclGetProcessGlobalValue+0x23b
000000006E84C2EF 000000006E92F110 000000006E92F108 0000000000345580  tcl91.dll!InitializeEncodingSearchPath+0xbf
000000006E8FB4BB 000000000022FCD8 000000000022FCD8 0000000000650735  tcl91.dll!TclGetProcessGlobalValue+0x23b
000000006E84F52C 0000000000000000 000000006E7C0000 0000000000000000  tcl91.dll!Tcl_GetEncoding+0xac
000000006E850CE5 0000000000000000 0000000000000000 0000000000646470  tcl91.dll!Tcl_SetSystemEncoding+0x85
000000006E921700 0000000000401580 000007FE83858806 0000000000000000  tcl91.dll!TclpSetInitialEncodings+0x20
000000006E852878 00000000004018D0 0000000083858806 0000000000646470  tcl91.dll!Tcl_FindExecutable+0x18
000000006E90EC90 000000000000003E 0000000000000000 0000000000646470  tcl91.dll!TclZipfs_AppHook+0x10
000000000040165B 0000000000000001 000000000048FF30 0000000000409978  tclsh91.exe!wmain+0x4b
00000000004013EE 0000000000000000 0000000000000000 0000000000000000  tclsh91.exe!__tmainCRTStartup+0x26e  [/home/abuild/rpmbuild/BUILD/mingw-w64-v7.0.0/mingw-w64-crt/crt/crtexe.c @ 334]
000000000040153B 0000000000000000 0000000000000000 0000000000000000  tclsh91.exe!mainCRTStartup+0x1b  [/home/abuild/rpmbuild/BUILD/mingw-w64-v7.0.0/mingw-w64-crt/crt/crtexe.c @ 223]
--
User Comments:
jan.nijtmans added on 2026-03-14 13:27:19:

Does [f4a4d699c2a63e43|this] help?


erikleunissen added on 2026-03-14 13:59:15:
I'm getting the same popup window and the same stack trace.

apnadkarni added on 2026-03-15 05:22:03:

Please try the bug-422b0414a3-apn branch. It worked for me in my 32-bit Win7 VM. I don't have a 64-bit VM to try. It should show a dialog about unsupported Windows and exit the application. Note this will impact all applications that link to Tcl (as I think it should).

I don't think manifest changes will have any effect, they only tell Windows how to lie to the application about version numbers :-(

I am pretty sure 91a1 uses API's not present in Win 7, which 91a0 might not have done. But I am actually surprised that tclsh ran and panic'ed. My expectation would be that the program would just refuse to load since all DLL imports would not be resolved. I don't understand why an explicit check in the code is necessitated.


jan.nijtmans added on 2026-03-16 07:47:11:

You could also use the function tclWinDebugPanic(). It does exactly the same if IsDebuggerPresent() returns false. Only if IsDebuggerPresent() is true it will output the message to the debugger.

Not a big deal at all.


jan.nijtmans added on 2026-03-16 07:57:50:

Hm. I almost forgot about TIP #425. tclWinDebugPanic() is the default panicproc since Tcl 9.0. So the comment "Do not use Tcl_PanicProc" doesn't make much sense here. (It would have made sense in Tcl 8!)


erikleunissen added on 2026-03-16 15:05:19:
@ apnadkarni :

Regarding:

> But I am actually surprised that tclsh ran and panic'ed. My expectation would
> be that the program would just refuse to load since all DLL imports would not 
> be resolved. I don't understand why an explicit check in the code is
> necessitated.

I understand. But since it does launch, the error message is confusing.

Regarding:

> Please try the bug-422b0414a3-apn branch. It worked for me in my 32-bit Win7 VM.
> I don't have a 64-bit VM to try. It should show a dialog about unsupported Windows
> and exit the application.

I tried it on a 64-bit machine. Indeed, the dialog shows, with a message that
provides much more useful information for the user.

Screen shot once more attached as Capture2.PNG

apnadkarni added on 2026-03-17 02:44:50:

Jan,

So the comment "Do not use Tcl_PanicProc" doesn't make much sense here.

The comment refers to Tcl_Panic not Tcl_PanicProc. The reason I do not want to call Tcl_Panic is that it exits with an int 3 which puts up another nasty dialog. Since we have already displayed a message to the user with cause for exit, I prefer a clean exit() as opposed to an int 3 exception.

You could also use the function tclWinDebugPanic().

TBH I thought, based on the name, that tclWinDebugPanic would panic (i.e. exit), not realizing it only displays a message. Still, during initialization time when all Tcl subsystems may or may not have been fully initialized, my preference would be to use direct Win32 calls and not Tcl facilities to exit. However, I'm ok with your changing it to tclWinDebugPanic if you prefer that.


jan.nijtmans added on 2026-03-17 09:04:03:

Thanks for fixing this.

> However, I'm ok with your changing it to `tclWinDebugPanic` if you prefer that.

It's just a choice, not actually better or so. I'll leave it as it is now, which is fine.


oehhar added on 2026-03-17 10:21:17:

May the manifest removal in [368f7fdda0a2de37] change MS-WIN oS behavior? May Windows 11 already issue a warning automatically?

Thanks, Harald


jan.nijtmans added on 2026-03-17 12:18:03:

> May the manifest removal in [368f7fdda0a2de37] change MS-WIN oS behavior? May Windows 11 already issue a warning automatically?

No and No. Erik (see below) reported there is no change of behavior at all.


Attachments: