WT disappears after 3 days!? #19606

Closed
opened 2026-01-31 06:48:32 +00:00 by claunia · 18 comments
Owner

Originally created by @vefatica on GitHub (Mar 29, 2023).

Windows Terminal version

WindowsTerminalPreview: 1.17.2301.23004

Windows build number

10.0.19045.2728 (2009, 22H2)

Other Software

Using TCC shell as a testing platform.

Steps to reproduce

Start WT and wait 3 days.

Expected Behavior

It continues to run.

Actual Behavior

It unceremomiously terminates with no local dump file.

In Fall 2022, I started to notice WT not running when I expected it to be running. This happened several times during fall and winter and always seemed to happen after about 3 days. Once, I witnessed WT disappearing while I was playing solitaire! So finally I did a test.

With a TCC batch file running outside WT, I logged the start time of WT (from WMI) and I used MsgWaitForMultipleObjectsEx on a HANDLE to the WT process (and a wait_cancel_event HANDLE). Not having cancelled the wait, I logged the time (current local system time) when WT terminated. Here's the log file.

WindowsTerminal.exe (PID 10460) started: 2023-03-26 03:00:51
WindowsTerminal.exe (PID 10460) terminated: 2023-03-29 03:00:54

Notes: I'm pretty sure you can't blame the shell because in those 3 days, what shells were running in WT changed several times, and none were running for the whole 3 days. And you can't blame me because I was in dreamland when the test ended. As I said before, there was no local dump file (local dumps are enabled).

I'd be happy to test further but I can't think of any good tests. I'm pretty confident the same test will produce the same result.

Originally created by @vefatica on GitHub (Mar 29, 2023). ### Windows Terminal version WindowsTerminalPreview: 1.17.2301.23004 ### Windows build number 10.0.19045.2728 (2009, 22H2) ### Other Software Using TCC shell as a testing platform. ### Steps to reproduce Start WT and wait 3 days. ### Expected Behavior It continues to run. ### Actual Behavior It unceremomiously terminates with no local dump file. In Fall 2022, I started to notice WT not running when I expected it to be running. This happened several times during fall and winter and always seemed to happen after about 3 days. Once, I witnessed WT disappearing while I was playing solitaire! So finally I did a test. With a TCC batch file running outside WT, I logged the start time of WT (from WMI) and I used MsgWaitForMultipleObjectsEx on a HANDLE to the WT process (and a wait_cancel_event HANDLE). Not having cancelled the wait, I logged the time (current local system time) when WT terminated. Here's the log file. WindowsTerminal.exe (PID 10460) started: 2023-03-26 03:00:51 WindowsTerminal.exe (PID 10460) terminated: 2023-03-29 03:00:54 Notes: I'm pretty sure you can't blame the shell because in those 3 days, what shells were running in WT changed several times, and none were running for the whole 3 days. And you can't blame me because I was in dreamland when the test ended. As I said before, there was no local dump file (local dumps are enabled). I'd be happy to test further but I can't think of any good tests. I'm pretty confident the same test will produce the same result.
claunia added the Needs-TriageIssue-BugNeeds-Attention labels 2026-01-31 06:48:33 +00:00
Author
Owner

@carlos-zamora commented on GitHub (Mar 29, 2023):

Hi @vefatica. Could you please capture an ETL trace of this occurring?

@carlos-zamora commented on GitHub (Mar 29, 2023): Hi @vefatica. Could you please [capture an ETL trace](https://github.com/microsoft/terminal/wiki/Capturing-a-Debug-ETL-Trace) of this occurring?
Author
Owner

@vefatica commented on GitHub (Mar 29, 2023):

I don't see anything downloadable there. Please give precise downloading instructions.

I didn't mention earlier ... in my test, WT was (and is almost always) running elevated. I'll bet the actual time was exactly 3 days. I know where the extra 3 seconds came from (my own time-sync/clock-skew service).

@vefatica commented on GitHub (Mar 29, 2023): I don't see anything downloadable there. Please give precise downloading instructions. I didn't mention earlier ... in my test, WT was (and is almost always) running elevated. I'll bet the actual time was exactly 3 days. I know where the extra 3 seconds came from (my own time-sync/clock-skew service).
Author
Owner

@zadjii-msft commented on GitHub (Mar 29, 2023):

  1. Click on "Terminal.wprp file from this repository"
  2. Click on the download button:
    image
    (This may look different depending on pace of GH feature rollout)
@zadjii-msft commented on GitHub (Mar 29, 2023): 1. Click on "[Terminal.wprp file from this repository](https://github.com/microsoft/terminal/blob/main/src/Terminal.wprp)" 2. Click on the download button: ![image](https://user-images.githubusercontent.com/18356694/228677526-2aaeb88f-a93a-4fd3-8023-3b13660a331a.png) (This may look different depending on pace of GH feature rollout)
Author
Owner

@vefatica commented on GitHub (Mar 29, 2023):

If you mean this,

image

"Terminal.wprp" not clickable.

@vefatica commented on GitHub (Mar 29, 2023): If you mean this, ![image](https://user-images.githubusercontent.com/61856645/228678987-d442f682-5b16-4ed4-9d93-4709f03c7284.png) "Terminal.wprp" not clickable.
Author
Owner

@DHowett commented on GitHub (Mar 30, 2023):

CLICK THIS
image

It is the universally accepted icon for "download".

@DHowett commented on GitHub (Mar 30, 2023): CLICK THIS <img width="33" alt="image" src="https://user-images.githubusercontent.com/189190/228689311-1579da64-fbe6-4c73-b110-2ef3a1b1be93.png"> It is the universally accepted icon for "download".
Author
Owner

@vefatica commented on GitHub (Mar 30, 2023):

Apparently I'm not seeing what you're seeing.

image

@vefatica commented on GitHub (Mar 30, 2023): Apparently I'm not seeing what you're seeing. ![image](https://user-images.githubusercontent.com/61856645/228699623-86c81411-7599-4254-91d4-62c829656c22.png)
Author
Owner

@DHowett commented on GitHub (Mar 30, 2023):

What on earth?!

Okay, for now, uh... click on "Raw", and use Ctrl+S

I think I'm going crazy! Sorry! :)

@DHowett commented on GitHub (Mar 30, 2023): _What on earth?!_ Okay, for now, uh... click on "Raw", and use <kbd>Ctrl+S</kbd> I think I'm going crazy! Sorry! :)
Author
Owner

@vefatica commented on GitHub (Mar 30, 2023):

That just downloads Terminal.wprp.txt with the XML in it.

@vefatica commented on GitHub (Mar 30, 2023): That just downloads Terminal.wprp.txt with the XML in it.
Author
Owner

@DHowett commented on GitHub (Mar 30, 2023):

Then rename it! You're the one who thought injecting a remote thread into Explorer to set environment variables was a good plan - I know you can handle a little XML file with the wrong extension! 😁

@DHowett commented on GitHub (Mar 30, 2023): Then rename it! You're the one who thought injecting a remote thread into Explorer to set environment variables was a good plan - I know you can handle a little XML file with the wrong extension! 😁
Author
Owner

@vefatica commented on GitHub (Mar 30, 2023):

I know epsilon about XML and obviously even less about exactly what's supposed to happen here. Rename it what? And then what?

@vefatica commented on GitHub (Mar 30, 2023): I know epsilon about XML and obviously even less about exactly what's supposed to happen here. Rename it what? And then what?
Author
Owner

@vefatica commented on GitHub (Mar 30, 2023):

OK. I think I have this figured out. Will this (below) work?

Wait until the expected disappearance of WT is imminent That's now somewhat less than 3 days.

wpr -start v:\Terminal.wprp!Terminal.Verbose

After WT has disappeared ...

wpr -stop terminal-trace.etl

zip the ETL file and post/send it.

@vefatica commented on GitHub (Mar 30, 2023): OK. I think I have this figured out. Will this (below) work? Wait until the expected disappearance of WT is imminent That's now somewhat less than 3 days. wpr -start v:\Terminal.wprp!Terminal.Verbose After WT has disappeared ... wpr -stop terminal-trace.etl zip the ETL file and post/send it.
Author
Owner

@DHowett commented on GitHub (Mar 30, 2023):

That'll work for us! Thanks, and sorry about the download confusion.

@DHowett commented on GitHub (Mar 30, 2023): That'll work for us! Thanks, and sorry about the download confusion.
Author
Owner

@vefatica commented on GitHub (Mar 30, 2023):

And I apologize for being slow to figure it out. At first I thought I would be downloading the WPR tool. Then I found it here already and figured out that I only needed the XML.

I'm also new to PerfView, just learned of it yesterday. Should I be able to view a trace, made as described above, with PerfView? I have symbols (maintained by WinDbg).

@vefatica commented on GitHub (Mar 30, 2023): And I apologize for being slow to figure it out. At first I thought I would be downloading the WPR tool. Then I found it here already and figured out that I only needed the XML. I'm also new to PerfView, just learned of it yesterday. Should I be able to view a trace, made as described above, with PerfView? I have symbols (maintained by WinDbg).
Author
Owner

@vefatica commented on GitHub (Apr 1, 2023):

Right on schedule, WT disappeared 3 days after it was started. Here's a bit of a transcript. The zipped ETL file is attached but, to be honest, it doesn't look very interesting. I started the trace about 10 minutes before the disappearance. In the last three days my w32tmsvc added 2.5 seconds to the system clock, explaining, I reckon, the difference between 3 days and the observation below.

v:\> wpr -start v:\Terminal.wprp!Terminal.Verbose

v:\> set pid=%@wmi[.,"select processid from Win32_Process where Caption='windowsterminal.exe'"] & echo Start: %@wmitcvt[%@wmi[.,
"select CreationDate from Win32_Process where ProcessId=%pid"],T] & wait /p %pid & echo Stop:  %_date %_t9
Start: 2023-03-29 11:42:42.788
Stop:  2023-04-01 11:42:45.373

v:\> wpr -stop terminal-trace.etl

v:\> zip disappear.zip terminal-trace.etl
<= V:\terminal-trace.etl

disappear.zip

@vefatica commented on GitHub (Apr 1, 2023): Right on schedule, WT disappeared 3 days after it was started. Here's a bit of a transcript. The zipped ETL file is attached but, to be honest, it doesn't look very interesting. I started the trace about 10 minutes before the disappearance. In the last three days my w32tmsvc added 2.5 seconds to the system clock, explaining, I reckon, the difference between 3 days and the observation below. ``` v:\> wpr -start v:\Terminal.wprp!Terminal.Verbose v:\> set pid=%@wmi[.,"select processid from Win32_Process where Caption='windowsterminal.exe'"] & echo Start: %@wmitcvt[%@wmi[., "select CreationDate from Win32_Process where ProcessId=%pid"],T] & wait /p %pid & echo Stop: %_date %_t9 Start: 2023-03-29 11:42:42.788 Stop: 2023-04-01 11:42:45.373 v:\> wpr -stop terminal-trace.etl v:\> zip disappear.zip terminal-trace.etl <= V:\terminal-trace.etl ``` [disappear.zip](https://github.com/microsoft/terminal/files/11129977/disappear.zip)
Author
Owner

@vefatica commented on GitHub (Apr 2, 2023):

Solved! "Stop the task if it runs longer than 3 days" is a default setting of Task Scheduler which I never paid much attention to. I typically start WT via an AutoHotKey script executing u:\schtasksw.exe /run /tn wtelevated. Schtasksw.exe is a GUI version of schtasks.exe (made with editbin.exe) and the "wtelevated" task is on-demand with highest privileges. Starting WT in this way avoids the UAC prompt. Sorry about the false alarm.

I'm still curious. Did terminal-trace.etl work as expected? ... have anything in it about what WT was doing?

@vefatica commented on GitHub (Apr 2, 2023): Solved! "Stop the task if it runs longer than 3 days" is a default setting of Task Scheduler which I never paid much attention to. I typically start WT via an AutoHotKey script executing `u:\schtasksw.exe /run /tn wtelevated`. Schtasksw.exe is a GUI version of schtasks.exe (made with editbin.exe) and the "wtelevated" task is on-demand with highest privileges. Starting WT in this way avoids the UAC prompt. Sorry about the false alarm. I'm still curious. Did terminal-trace.etl work as expected? ... have anything in it about what WT was doing?
Author
Owner

@zadjii-msft commented on GitHub (Apr 4, 2023):

Well, that's wild, but a good new thing to learn about!

The .etl did work perfectly fine. From what's in there, it looks like the Terminal was doing... nothing. Not processing any data, not opening new tabs or anything, just hanging out. There was a few events for the regularly scheduled "let's make sure we persist all the window positions" thread, but really nothing else interesting. Nothing in there would indicate a crash, but that's cause it didn't, so neato!

Thanks for following up!

@zadjii-msft commented on GitHub (Apr 4, 2023): Well, that's wild, but a good new thing to learn about! The .etl did work perfectly fine. From what's in there, it looks like the Terminal was doing... nothing. Not processing any data, not opening new tabs or anything, just hanging out. There was a few events for the regularly scheduled "let's make sure we persist all the window positions" thread, but really nothing else interesting. Nothing in there would indicate a crash, but that's cause it _didn't_, so neato! Thanks for following up!
Author
Owner

@vefatica commented on GitHub (Apr 4, 2023):

Using PerfView, could I have learned from the .ETL file what you learned (however little there was to learn)? Do you use PerfView or a different tool?

It's comforting to know that when Task Scheduler says "3 days" it means 3 days! :-)

@vefatica commented on GitHub (Apr 4, 2023): Using PerfView, could I have learned from the .ETL file what you learned (however little there was to learn)? Do you use PerfView or a different tool? It's comforting to know that when Task Scheduler says "3 days" it means 3 days! :-)
Author
Owner

@zadjii-msft commented on GitHub (Apr 4, 2023):

Probably, but I haven't ever learned to use that lmao. I use an internal tool just dumps the tracelogging events, which is what I was looking for. PerfView would probably have quite a bit more info than even that.

@zadjii-msft commented on GitHub (Apr 4, 2023): Probably, but I haven't ever learned to use that lmao. I use an internal tool just dumps the tracelogging events, which is what I was looking for. PerfView would probably have quite a bit more info than even that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19606