ConPty somethimes hangs when calling ClosePseudoConsole
, (pseudo console created with PSUEDOCONSOLE_INHERIT_CURSOR
)
#17716
Replies: 8 comments 2 replies
-
Regarding that In #17510 I added a timeout to cursor inheritance so in the worst case it will only block for 3 seconds. I was about to repurpose this issue to track the remaining problem: A shutdown signal should kill ConPTY instantly and not only after 3 seconds (hence the edits on your message). But then I realized that I also fixed that, so I think this has actually fundamentally been fixed in that PR. However, then I also realized that this can't cause the freeze on shutdown. I've replaced ConPTY with a build from I don't know whether that causes your specific deadlock, but wezterm does definitely (and unfortunately) make the primary mistake when using the ConPTY API: It fails to read from the output pipe when calling To reproduce the issue, run a child process inside your shell (for instance WSL), print a ton of text in large chunks (for instance with This is one of the reasons why I've chosen to remove the blocking wait from the My suggestion for wezterm is that it reads from the output pipe until With the next version of ConPTY at the end of this month, the new, safer API will be available. It'll allow you to safely call P.S.: I just noticed that wezterm calls it "psuedo". Not just the flag, but also the entire file ("psuedocon.rs"). 😅 |
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick reply. I’m a regular Wezterm user, what i noticed is that ClosePseudoConsole is blocking indefinitely (definitely more than 3 seconds). Next week I should be able (hopefully will be easy) to compile conpty.dll from this repo from the main branch and reproduce the test wit ‘cat’ and closing the term. Psuedocon typo i can report it back to wezterm devs, doing a pr with the rename might be received as inappropriate. Regarding your reafile suggestion sounds something like I could try to make a patch for but apart from referring tour comment i am not sure i will be able to skillfully respond any questions reviewers might ask. PS: how did you catch de deadlock stack? With procdump, could you give some details on that? |
Beta Was this translation helpful? Give feedback.
-
If you hit any problems and got questions, please let me know! I'll try to get the ConPTY API updated by then.
If the reviewers have any questions specific to ConPTY and you aren't sure about, please feel free to ping me. 🙂 (I'm familiar with Rust so that shouldn't be a problem either. 😅)
That's Process Hacker, now renamed System Informer (probably to avoid getting banned by non-IT admins). It's similar to Microsoft's own Process Explorer, but in my opinion it's better because I find it visually more pleasing, it has more features, and it's open source on GitHub. Stacks can be observed by double-clicking any application, clicking on "Threads", sorting by TID (so that their order is stable and stops changing), and click each individual thread. System Informer will automatically download PDBs and resolve symbols for you. Of course, this only works for basic triage, but in my experience that's often enough to get an initial idea of the problem. That aside, if you open its Options dialog, you'll find a ton of features that you can optionally enable. I wouldn't recommend enabling them outright, but I think it's worth toying around with them. Something I use for basic testing of our text renderer for instance, is under "ExtendedTools". There, you can check "Enable FPS monitoring" and you'll be able to see DWM present statistics for each individual application. All of these are also super useful: These are great: You can alternatively also click this button: These are completely nuts: None of this requires a kernel driver, and it really only scratches the surface. System Informer is one of the greatest Windows apps I know. |
Beta Was this translation helpful? Give feedback.
-
Leonard thanks for the crash course on Process Informer, in the passt I installed but felt overwehlmed the the amount of options and I used to use only I am trying to give you some more info to make sure what we see it's the same issue you described, today it hanged again and decided to collect infos the way you showed me. The main problem was identifying which Since I did not now which Out of those dumps I could see Openconsole (most of them having a similar stack) Except one, which was showing something with Observations
Next
PS: I am happy to learn better ways of doing things, please feel free to suggest me at any time how you would do it if you know a nicer way. |
Beta Was this translation helpful? Give feedback.
-
When you check out these older OpenConsole versions (prior to #17510), you need to check the stack of the If I'm correct, then that's why the |
Beta Was this translation helpful? Give feedback.
-
building conpty.dllI will need some help building the latest conpty.dll, I read I got some errors
Despite the errors I got a conpty.dll built.
Sadly I can't see it's version, I guess because I am building directly from master.. cat bigfile experimentI tried to cat and close a pane with a 1MB file big, yes the term blocked but eventually it got closed as soon as cat was done doing it's thing. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@lhecker in pr wez/wezterm#5977 I added the following commit wez/wezterm@a25e7be, so far and doesn't look like I broke anything but if you could check if I am doing something stupid would be great. Can I read from the output pipeline like this before calling Off topic: what do you use for making these nice screenshot guides, I use gimp normally but I don't have a nice way of producing boxes and numbers, again thanks in advance for you advice. |
Beta Was this translation helpful? Give feedback.
-
Other Software
wezterm 20240807-131622-ee063330
I am opening an issue here because as I understood conpty code lives here in this repo
Steps to reproduce
Sadly we couldn't manage to get consistent way to reproduce this.
We see wezterm in windows sometimes hanging when closing panes, e.g. wez/wezterm#5882
I am suspecting this might be related to #1810
this comment points out to a race condition, when ConPTY is being started with
CreatePseudoConsole()
with the flagPSEUDOCONSOLE_INHERIT_CURSOR
(which wezterm does) this kind of fit with the fact we can't consistenly reproduce this issue.Here the start call in wezterm.
Actual Behavior
ClosePseudoConsole
hangsBeta Was this translation helpful? Give feedback.
All reactions