View Ticket
Not logged in
2022-08-20
17:09
Merged fix for bug [baa51423c2] check-in: 87687f362f user: apnadkarni tags: trunk, main
16:56
Added test for bug [baa51423c2] check-in: 90989a0ac8 user: apnadkarni tags: core-8-branch
13:17 Ticket [baa51423c2] tclWinConsole: needEvent variable is used uninitialized status still Closed with 5 other changes artifact: b7a059fd69 user: fvogel
12:16
Really closes [baa51423c28a3baf] check-in: 189e348c49 user: apnadkarni tags: core-8-branch
11:55 Ticket [baa51423c2] tclWinConsole: needEvent variable is used uninitialized status still Closed with 4 other changes artifact: 80e47ad075 user: apnadkarni
11:53 Ticket [baa51423c2]: 5 changes artifact: e29b321fec user: apnadkarni
10:37 Closed ticket [baa51423c2]. artifact: 5b62a3191f user: sebres
10:36 Ticket [baa51423c2]: 3 changes artifact: f3c587148c user: sebres
10:13
closes [baa51423c28a3baf]: needEvent must be initialized in cycle (for each watching channel) check-in: fce5cfe1c7 user: sebres tags: core-8-branch
07:05 Ticket [baa51423c2] tclWinConsole: needEvent variable is used uninitialized status still Open with 4 other changes artifact: 52ec2a6684 user: fvogel
07:04 New ticket [baa51423c2]. artifact: 2e1c732755 user: fvogel

Ticket UUID: baa51423c28a3baf31271b979bd18cf58116a77c
Title: tclWinConsole: needEvent variable is used uninitialized
Type: Bug Version: core-8-branch
Submitter: fvogel Created on: 2022-08-20 07:04:13
Subsystem: 52. Portability Support Assigned To: apnadkarni
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2022-08-20 13:17:23
Resolution: Fixed Closed By: fvogel
    Closed on: 2022-08-20 13:17:23
Description:

Since [c085b9090c8ae821] (New Windows console driver. Fixes [21280817d1] thread proliferation and [44bbccdd8c] fconfigure std{out,err}.), in a freshly built Tcl from core-8-branch, when running "package require Tk" I get a MSVC Runtime Library debug check triggering: "Run-Time Check Failure #3: The variable 'needEvent' is being used without being initialized."

I believe this comes from a missing initialization in ConsoleCheckProc in tclWinConsole.c:838 but there must be something more about this because when I add this initialization:

int needEvent = 0;

then the console runs (run-time check error is gone) but the continuation lines are broken in the console: it is no longer possible to enter more characters. Example: just enter: "proc a {} {", hit the enter key and it's stuck.

User Comments: fvogel added on 2022-08-20 13:17:23:

Comfirm [189e348c49] works for me. Thanks!


apnadkarni added on 2022-08-20 11:55:46:
As an aside, I'm a little surprised the compiler did not warn of uninitialized use. I thought they would.

apnadkarni added on 2022-08-20 11:53:52:
Found the issue and fixed it. Testing now.

@sebres - just initializing needEvent does not suffice.

@sebres - regarding lock deadlocks, pretty much all my code (here, iocp, isapi) uses lock hierarchies to prevent deadlocks. See comments in the code (search for hierarchy)

/Ashok

sebres added on 2022-08-20 10:36:36:

Fixed in [fce5cfe1c7e872fe]...

Just I must admit, I saw something that may be potentially dangerous:

ConsoleCheckProc locks two mutexes in a nested way. This is theoretically a candidate for a deadlock in certain circumstances.
Ashok, can we be sure there are no constellations where it could happen?
I mean TH-A locks gConsoleLock and want to lock handleInfoPtr->lock, in the same time TH-B that still hold the lock on handleInfoPtr->lock attempting to lock gConsoleLock for some reason, what would cause a freezing. We can have one actor more that (especially by read/write locks) make some exclusive (W) lock for some of them, so finally it could lead to hardly reproducible heisenbug.


fvogel added on 2022-08-20 07:05:02:
Ashok, may I assign to you since you touched this very recently? Thanks!