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

Segmentation fault when using requests/pynetbox with pyATS on Apple Silicon macOS #252

Open
geortich opened this issue Nov 17, 2024 · 5 comments
Assignees

Comments

@geortich
Copy link

geortich commented Nov 17, 2024

Description

When using the requests library (directly or via pynetbox) with pyATS on macOS with Apple Silicon, the process crashes with a segmentation fault during fork pre-exec. The same code works perfectly when run in a Linux environment (Docker).

Environment

  • OS: macOS Sonoma 14.4.1 and 14.7.1 (tested on both M1 and M2 architectures)
  • Python: 3.11, 3.12.5 and 3.12.7
  • pyATS: 24.7, 24.9, and 24.10 (issue present in all versions)
  • requests: 2.31.0 and 2.32.3 (issue present in both versions)
  • Architecture: Apple Silicon (M1 and M2)
  • HTTP or HTTPS API calls

Steps to Reproduce

  1. Create a simple test using requests within pyATS:
from pyats import aetest
import logging
import requests

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

class TestRequests(aetest.Testcase):
    @aetest.setup
    def setup(self):
        self.url = "http://jsonplaceholder.typicode.com/posts/1"

    @aetest.test
    def test_simple_request(self):
        response = requests.get(self.url)
        logger.info(f"Response status code: {response.status_code}")
  1. Run with easypy:
from pyats.easypy import run

def main():
    run(
        testscript="test.py",
        taskid="Simple_Request_Test"
    )

Error output

Python crashes with a cryptic error, Stopping Context.
However, mac OS produces a crash report with the following details

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000110
Exception Codes:       0x0000000000000001, 0x0000000000000110
Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [PROCESS_ID]
Application Specific Information:
*** multi-threaded process forked ***
crashed on child side of fork pre-exec
@geortich
Copy link
Author

Although documentation says that python 3.10.x is the latest supported for 24.10 this https://developer.cisco.com/docs/pyats/24-2/ says that support for 3.12.x has been added in 24.2.

@sowmyadn010501
Copy link

Hi, Kindly give me some time to check on this issue

@geortich
Copy link
Author

thanks @sowmyadn010501. Let me know if you need any other logs from my end.

@sowmyadn010501
Copy link

Hello geortich,
We have found the workaround, that is to disable network proxy lookups by defining the environment variable 'no_proxy' with value '*', for example os.environ ['no_proxy'] = '*'. For more info please check this attached case python/cpython#74570. Kindly let us know if it helps meanwhile we will also check on how we can get it done by default using pyats.
Thanks.

@geortich
Copy link
Author

geortich commented Dec 2, 2024

Hi @sowmyadn010501 ,
Thank you very much for the workaround. This approach works with python 3.11.5 (I haven't tested other versions in the 3.11 branch) but not with 3.12.5 or 3.12.7.

I hope this gets resolved natively in a future pyATS release.

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