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

Crash on functions accepting callbacks & positional arguments to them typed with TypeVarTuple #7141

Closed
Enegg opened this issue Jan 27, 2024 · 2 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@Enegg
Copy link

Enegg commented Jan 27, 2024

Describe the bug
While type checking code below pyright hangs indefinitely.

Code or Screenshots

from collections import abc
from typing_extensions import TypeVar, TypeVarTuple, Unpack

T = TypeVar("T")
PosArgsT = TypeVarTuple("PosArgsT")

def call(func: abc.Callable[[Unpack[PosArgsT]], T], *args: Unpack[PosArgsT]) -> T:
    return func(*args)

def callback(num: int, /) -> int:
    return num

call(call, call, callback, 123)

Code tested in pyright playground gets no response from the server:

image
(introduce any kind of error like foo: str = 123, it gets no response)

Pylance indefinitely analyzes the file, causing VSCode to have high CPU usage and constantly allocating more memory, until it eventually crashes.

Output log
2024-01-27 20:48:34.828 [info] [Info  - 8:48:34 PM] (18856) Background analysis(3) started

# file opened around 20:56

2024-01-27 21:03:46.484 [info] 
<--- Last few GCs --->

[18856:0000591C00340000]   919106 ms: Mark-Compact 1990.0 (2065.2) -> 1987.0 (2070.2) MB, 3812.95 / 0.00 ms  (average mu = 0.359, current mu = 0.188) allocation failure; scavenge might not succeed
[18856:0000591C00340000]   924837 ms: Mark-Compact 1994.7 (2070.2) -> 1990.6 (2073.7) MB, 5643.50 / 0.00 ms  (average mu = 0.174, current mu = 0.015) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

2024-01-27 21:03:46.599 [info]  1: 00007FF717BD2786 node::SetTracingController+80086
 2: 00007FF717BD2A13 node::OnFatalError+595
 3: 00007FF71A8C19B3 v8::Function::NewInstance+835
 4: 00007FF71A8C1943 v8::Function::NewInstance+723
 5: 00007FF71A98A367 v8::CppHeap::CollectGarbageInYoungGenerationForTesting+74791
 6: 00007FF7194D1594 v8::MicrotasksScope::PerformCheckpoint+543732
 7: 00007FF7194CC8ED v8::MicrotasksScope::PerformCheckpoint+524109

2024-01-27 21:03:46.599 [info]  8: 00007FF7194BCCE7 v8::MicrotasksScope::PerformCheckpoint+459591
 9: 00007FF7196C7C73 v8::MicrotasksScope::PerformCheckpoint+2601683
10: 00007FF7199E4D3A v8_inspector::String16::String16+2535050
11: 00007FF71994FDD2 v8_inspector::String16::String16+1924898
12: 00007FF77A88FFF9 

2024-01-27 21:03:46.950 [info] [Error - 9:03:46 PM] Server process exited with code 134.
2024-01-27 21:03:46.959 [info] [Info  - 9:03:46 PM] Connection to server got closed. Server will restart.
2024-01-27 21:03:46.959 [info] true
2024-01-27 21:03:48.403 [info] [Info  - 9:03:48 PM] (18192) Pylance language server 2024.1.101 (pyright version 1.1.348, commit cfb1de0c) starting

VS Code extension or command-line
VS Code extension - Pylance v2024.1.101 (prerelease)

@Enegg Enegg added the bug Something isn't working label Jan 27, 2024
@erictraut
Copy link
Collaborator

Thanks for the bug report. I'm able to repro the problem as described. I'll investigate further.

erictraut added a commit that referenced this issue May 21, 2024
…es an `*args: *Ts` parameter is passed as an argument to itself. This partially addresses #7141.
erictraut added a commit that referenced this issue May 21, 2024
…es an `*args: *Ts` parameter is passed as an argument to itself. This partially addresses #7141. (#7964)
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label May 21, 2024
@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.364.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants