CiscoTestAutomation / pyats

Cisco DevNet pyATS Test Framework Bug Tracker
Apache License 2.0
152 stars 32 forks source link

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

Open geortich opened 5 days ago

geortich commented 5 days ago

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

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 commented 4 days ago

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 commented 2 days ago

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

geortich commented 14 hours ago

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