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

fatal runtime error: stack overflow when running a test that makes use of astroid #1

Open
leynos opened this issue Nov 24, 2024 · 2 comments

Comments

@leynos
Copy link

leynos commented Nov 24, 2024

Output:

% ξ‚° poetry run xc
xc πŸƒ (Python 3.13.0 (main, Oct  7 2024, 05:02:14) [Clang 15.0.0 (clang-1500.3.9.4)] darwin)
   Found 1 tests from 1 files in 0.00s
           [       0s] β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘      0/1
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
zsh: abort      poetry run xc

Pyproject.toml:

[tool.poetry]
name = "empty"
version = "0.1.0"
description = ""
authors = ["Payton McIntosh <payton.mcintosh@___.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.13"
astroid = "^3.3.5"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

test_empty.py:

import astroid

def test_empty():
    source_code = """
    def foo(bar: str) -> int:
        return len(bar)
    """
    tree = astroid.parse(source_code)
    assert tree

Another example giving the same results:

xc πŸƒ (Python 3.13.0 (main, Oct  7 2024, 05:02:14) [Clang 15.0.0 (clang-1500.3.9.4)] darwin)
   Found 1 tests from 1 files in 0.00s
           [       0s] β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘      0/1
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
zsh: abort      poetry run xc test_yarl.py

pyproject.toml:

[tool.poetry]
name = "xc-yarl"
version = "0.1.0"
description = ""
authors = ["Payton McIntosh <payton.mcintosh@___.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.13"
yarl = "^1.18.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

test_yarl.py:

from yarl import URL

def test_yarl():
    foo = URL('http://foo.com/')
    assert foo / 'bar'

This is on Apple Silicon / Mac OS v14.7.1 (23H222):

% ξ‚° uname -a
Darwin EDI-MAC-PaytonM 23.6.0 Darwin Kernel Version 23.6.0: Thu Sep 12 23:36:23 PDT 2024; root:xnu-10063.141.1.701.1~1/RELEASE_ARM64_T6031 arm64
% ξ‚° cargo --version
cargo 1.81.0 (2dbb1af80 2024-08-20)

Any other information I can provide to be of assistance?

@brownben
Copy link
Owner

Hey! I'm sorry you're having issues. Unfortunately, I can't reproduce the problem you're having.

I have added your examples as tests, and they are passing in CI (bdd55e3).
I have also added MacOS to run in CI, and the new tests are passing on MacOS as well.

I also cannot reproduce when I run locally on Windows 11, with Rust 1.81 or Nightly, and with Python 3.12 or 3.13.

Does it happen every time you run it? Or does it sometimes succeed?

@leynos
Copy link
Author

leynos commented Nov 28, 2024

Building with the latest version of the repository seems to fix things:

% ξ‚° git pull
remote: Enumerating objects: 76, done.
remote: Counting objects: 100% (52/52), done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 76 (delta 34), reused 45 (delta 31), pack-reused 24 (from 1)
Unpacking objects: 100% (76/76), 23.46 KiB | 667.00 KiB/s, done.
From https://github.com/brownben/xc
   f508b82..fe2405d  main       -> origin/main
Updating f508b82..fe2405d
Fast-forward
[package]
 .github/workflows/ci.yml           |   5 +-
 README.md                          |   2 +
 src/config.rs                      |  29 ++++-
 src/coverage.rs                    |  90 ++++++++------
 src/main.rs                        |  36 ++++--
 src/output/json.rs                 |   7 +-
 src/output/standard.rs             |  12 +-
 src/python.rs                      | 589 -----------------------------------------------------------------------------------------
 src/python/interpreters.rs         | 127 +++++++++++++++++++
 src/python/mod.rs                  |  20 +++
 src/python/objects.rs              | 400 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/python/operations.rs           | 246 +++++++++++++++++++++++++++++++++++++
 src/run.rs                         | 317 ++++++++++++++++++++++++++++++++++--------------
 tests/execution.rs                 |   2 +
 tests/execution/dependencies.py    |  24 ++++
 tests/output.rs                    |  60 +++++++++
 tests/output/failed_test_stdout.py |   3 +
 tests/requirements.txt             |   6 +
 18 files changed, 1234 insertions(+), 741 deletions(-)

Or at the very least, I now get a different panic:

% ξ‚° RUST_BACKTRACE=full poetry run ../xc/target/debug/xc test_astroid.py
xc πŸƒ (Python 3.13.0 (main, Oct  7 2024, 05:02:14) [Clang 15.0.0 (clang-1500.3.9.4)] darwin)
  Found 1 tests from 1 files in 0.00s
          [       0s] β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘      0/1     thread 'main' panicked at src/python/operations.rs:36:5:
assertion failed: !result.is_null()
...
Fatal Python error: _PyThreadState_Attach: non-NULL old thread state
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Shall I raise a separate issue for this error?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants