Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

PLS crashes when analyzing #503

Closed
erictraut opened this issue Dec 25, 2018 · 1 comment
Closed

PLS crashes when analyzing #503

erictraut opened this issue Dec 25, 2018 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@erictraut
Copy link

I'm seeing a consistent crash in the analyzer with the following simple python code:

import email
def foo():
    message = email.message_from_string("")
    message.walk()

I'm running this on MacOS in VSCode with a Python 3.6 virtual env. I'm using the latest version of the vscode python extension (2018.12.1) which contains version 0.1.72 of the PLS.

The crash occurs in the method PythonAnalyzer.GetTypeFromObject (which is called by PythonAnalyzer.GetAnalysisValueFromObjects). The problem is that the walk member is of type ILazyMember, so when GetTypeFromObject is called, it is not able to determine its type, and it calls Debug.Fail which crashes the server. The crash occurs repeatedly as long as the file is open, and VSCode kills the service after five crashes.

I think the correct fix is to add the following lines to PythonAnalyzer.GetAnalysisValueFromObjects:

            if (attr is ILazyMember lm) {
                var member = lm.Get();
                return GetAnalysisValueFromObjects(member);
            }

This resolves the lazy member and recursively calls GetAnalysisValueFromObjects to determine its type. I've confirmed that with this fix, the crash no longer occurs, but I'm not familiar enough with the analysis engine and its internal objects to say for sure that this is the correct fix.

@MikhailArkhipov MikhailArkhipov self-assigned this Dec 27, 2018
@MikhailArkhipov MikhailArkhipov added type-bug bug Something isn't working labels Dec 27, 2018
@MikhailArkhipov
Copy link

N/A after #546, this code no longer exist

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants