microsoft / pyright

Static Type Checker for Python
Other
13.12k stars 1.4k forks source link

Out of memory error under very specific circumstances #8723

Closed LeeeeT closed 1 month ago

LeeeeT commented 1 month ago

Starting with version 1.1.373, I am experiencing an out of memory error when using pyright to type check my project felis. Here's the workflow run. I tried to extract the minimal reproducible example as usual, but the best I was able to come up with is this sample. There's a lot of code consisting of several modules. If I touch a single line in any of these files the problem disappears. I presume pyright is entering an infinite loop while checking sample.function.add2 (when I was playing around with this code, pyright once revealed a very long type for this definition; and weirdly if I change some completely unrelated code in other modules, it somehow interferes pyright's behavior for the aforementioned line). Yeah, I am relying heavily on the undocumented parts of pyright and maybe my code should in fact fail to type check (that's a different question) but I think you would agree that crashing with an OOM error is unsatisfactory anyway. Please let me know if you need any additional details.

erictraut commented 1 month ago

Thanks as always for the bug report and the great repro steps.

Your code definitely pushes the boundaries of what's possible with the Python type system. However, I don't see anything that you're doing here that relies on undocumented behaviors. And I agree that pyright should never hang regardless of what code it is fed.

I've narrowed down the problem to a specific commit, but I need to do further work to root cause the problem.

LeeeeT commented 1 month ago

Thank you so much!

erictraut commented 1 month ago

This is addressed in pyright 1.1.376.