Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native Exception in winpty #29540

Closed
dbaeumer opened this issue Jun 27, 2017 · 13 comments
Closed

Native Exception in winpty #29540

dbaeumer opened this issue Jun 27, 2017 · 13 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug *duplicate Issue identified as a duplicate of another issue(s) terminal General terminal issues that don't fall under another label windows VS Code on Windows issues

Comments

@dbaeumer
Copy link
Member

  • VSCode Version: 1.14 test pas
  • OS Version: Windows

Executed a task in the terminal and got:

capture

@vscodebot vscodebot bot added new release terminal General terminal issues that don't fall under another label labels Jun 27, 2017
@dbaeumer dbaeumer changed the title Exception in winpty-agent Native Exception in winpty Jun 27, 2017
@Tyriar
Copy link
Member

Tyriar commented Jun 27, 2017

@dbaeumer what was the state of the terminal at the time? Hidden, uninitialised, visible?

Related: #27534

@Tyriar Tyriar added info-needed Issue requires more information from poster and removed new release labels Jun 27, 2017
@dbaeumer
Copy link
Member Author

It was not visible. And I saw it again today when starting VS Code out of dev and it tried to restore a terminal (no task runner). But I have no reliable steps to reproduce.

@vscodebot vscodebot bot closed this as completed Jul 4, 2017
@vscodebot
Copy link

vscodebot bot commented Jul 4, 2017

This issue has been closed automatically because it needs more information and has not had recent activity. Please refer to our guidelines for filing issues. Thank you for your contributions.

@dbaeumer
Copy link
Member Author

dbaeumer commented Jul 5, 2017

Reopening the issue since it has all information I have.

@dbaeumer dbaeumer reopened this Jul 5, 2017
@dbaeumer dbaeumer added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Jul 5, 2017
@dbaeumer
Copy link
Member Author

dbaeumer commented Jul 5, 2017

I see that now very frequently. Once or twice a day.

@Tyriar
Copy link
Member

Tyriar commented Jul 5, 2017

It's failing here https://github.com/rprichard/winpty/blob/ce9239af5d751195ea6982a41c7d71356ac9201c/src/libwinpty/winpty.cc#L852, meaning either winpty_t or winpty_spawn_config_t wasn't initialized correctly.

I'm guessing it was related to the config as an exception should have been thrown earlier if winpty_t
wasn't initialized correctly https://github.com/Tyriar/node-pty/blob/085f1b180f7cfbb66e6656dd8dc95dbde685351f/src/win/pty.cc#L211

@dbaeumer does your terminal config (shell, args, env, cwd) have any special characteristics? Unicode in one of them for example?

@dbaeumer
Copy link
Member Author

dbaeumer commented Jul 6, 2017

I saw it just failing with the following command line under Windows:

C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass Write-Host 'Invoking Pester...'; Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true}; Invoke-Command { Write-Host 'Completed Test task in task runner.' }

However I see the same exception when open a single terminal inside VS Code and even in Hyper.js from time to time.

@dbaeumer
Copy link
Member Author

dbaeumer commented Jul 6, 2017

Invoking the above command a second time worked. So might be a timing problem.

@Tyriar
Copy link
Member

Tyriar commented Jul 6, 2017

@rprichard can you think of any reason winpty_spawn_config_new might fail and return nullptr?

It seems to be happening sometimes for @dbaeumer and I verify the winpty_t so it much be the config failing https://github.com/Tyriar/node-pty/blob/085f1b180f7cfbb66e6656dd8dc95dbde685351f/src/win/pty.cc#L211

@rprichard
Copy link

@Tyriar

can you think of any reason winpty_spawn_config_new might fail and return nullptr?

AFAICT, out-of-memory is the only way it would return nullptr.

I'm guessing it was related to the config as an exception should have been thrown earlier if winpty_t
wasn't initialized correctly https://github.com/Tyriar/node-pty/blob/085f1b180f7cfbb66e6656dd8dc95dbde685351f/src/win/pty.cc#L211

I had noticed earlier that the call sites to Nan::ThrowError in pty.cc are inconsistent. Of the 7 calls, 3 of them return the value returned by Nan::ThrowError, 1 of them discards the return value but somewhat assumes that the function returns (i.e. it's followed by goto cleanup), and 3 of them assume the function doesn't return (implying setjmp or C++ exceptions).

I'm unfamiliar with the nodejs nan module, but my guess is that Nan::ThrowError does return.
I'm guessing it records the exception object somewhere so that a JavaScript object is thrown once the native function completes. ThrowError's return type is void, FWIW, but that doesn't really answer the question:

inline void ThrowError(v8::Local<v8::Value> error) {
    v8::Isolate::GetCurrent()->ThrowException(error);
}

I commented on this previously; maybe you didn't see it? It's here: #28593 (comment). "Aside: the control flow with Nan::ThrowError in node-pty is suspicious looking".

@dbaeumer
Copy link
Member Author

dbaeumer commented Jul 7, 2017

Got it today with Hyper.js. Here the screen shot.

capture

@Tyriar
Copy link
Member

Tyriar commented Jul 7, 2017

@rprichard yeah I haven't touched that stuff since I forked it https://github.com/chjj/pty.js/blob/master/src/win/pty.cc, can have a look at that in microsoft/node-pty#102. We've actually been seeing more out of memory crashes on Windows than other platforms recently so maybe that's related to this.

@Tyriar Tyriar added the windows VS Code on Windows issues label Jan 19, 2018
@Tyriar
Copy link
Member

Tyriar commented Jun 21, 2018

This is likely related to winpty, tracking in #45693

@Tyriar Tyriar closed this as completed Jun 21, 2018
@Tyriar Tyriar added the *duplicate Issue identified as a duplicate of another issue(s) label Jun 21, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Aug 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug *duplicate Issue identified as a duplicate of another issue(s) terminal General terminal issues that don't fall under another label windows VS Code on Windows issues
Projects
None yet
Development

No branches or pull requests

3 participants