Skip to content

Stack overflow crash with scipy.stats #2426

@bobybi930

Description

@bobybi930

Describe the Bug

Here is the code:

(test.py)

import scipy.stats as sps

prob = sps

When I put a dot at the end (prob = sps.), pyrefly crashes:

....
thread 'main' () has overflowed its stack
[Info  -  PM] Connection to server got closed. Server will restart.
true
starting generic LSP server
 INFO Reading messages
[Error - PM] Server process exited with code 3221225725.
 WARN PYTHONPATH environment variable is set to `...`. Checks in other environments may not include these paths.
 INFO File ...\test.py opened, prepare to validate open files.
 INFO Ran task on sourcedb_queue heavy task queue. Queue time: 0.00, task time: 0.00
 INFO Published 2 diagnostics for file://.../test.py
 INFO Validated open files and saved non-committable transaction.
 INFO Language server processed event `DidOpenTextDocument` in 0.24s (0.00s waiting)
 INFO Handling non-canceled request textDocument/completion (1)

thread 'main' () has overflowed its stack
[Error - PM] The Pyrefly language server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - PM] Server process exited with code 3221225725.

Expected behaviour: pyrefly doesn't crash, I get a list of options.

pyrefly.toml:

recursion-depth-limit = 10000
recursion-overflow-handler = "panic-with-debug-info"

With recursion-depth-limit = 0 it also crashes.

End of trace output:

[Trace - PM] Sending request 'textDocument/codeAction - (8)'.
Params: {
    "textDocument": {
        "uri": "file://.../test.py"
    },
    "range": {
        "start": {
            "line": 2,
            "character": 11
        },
        "end": {
            "line": 2,
            "character": 11
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 7
                    },
                    "end": {
                        "line": 2,
                        "character": 11
                    }
                },
                "message": "Module `scipy.stats.` exists, but was not imported explicitly. You are relying on other modules to load it.",
                "data": "non-committable-transaction",
                "code": "implicit-import",
                "codeDescription": {
                    "href": "https://pyrefly.org/en/docs/error-kinds/#implicit-import"
                },
                "severity": 1,
                "source": "Pyrefly"
            },
            {
                "range": {
                    "start": {
                        "line": 2,
                        "character": 11
                    },
                    "end": {
                        "line": 2,
                        "character": 11
                    }
                },
                "message": "Parse error: Expected an identifier",
                "data": "non-committable-transaction",
                "code": "parse-error",
                "codeDescription": {
                    "href": "https://pyrefly.org/en/docs/error-kinds/#parse-error"
                },
                "severity": 1,
                "source": "Pyrefly"
            }
        ],
        "triggerKind": 2
    }
}


[Trace - PM] Sending notification '$/cancelRequest'.
Params: {
    "id": 3
}

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

VSCodium info:
Version: 1.109.31074 (system setup)
Commit: 22dfe516eda675a2ce9ce2f2e78eabe4e7d9fece
Electron: 39.3.0
ElectronBuildId: undefined
Chromium: 142.0.7444.265
Node.js: 22.21.1
V8: 14.2.231.22-electron.0
OS: Windows_NT x64 10.0.19045

Python 3.13.12
pyrefly 0.52.0
scipy 1.15.2

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions