tkrebes / nisyscfg-python

NI System Configuration Python API
MIT License
4 stars 0 forks source link

[question] Getting some crashes in Ubuntu 20.04 while the code works in Windows 10 #38

Closed rscd27p closed 1 year ago

rscd27p commented 2 years ago

Hello tkrebes, thanks a lot for the work that you have put into this. I have tried using the nisyscfg-python both in Windows 10 and Ubuntu 20.04 with the kernel 5.13. However, some of the functions I have written have caused crashes in Ubuntu.

I am trying the function below on a cRIO-9049


def get_sw_and_feeds(target_name: str,username: str,password: str):
    print("Trying to connect to target: " + target_name)
    with nisyscfg.Session(target=target_name,username=username,password=password) as session: 
        print("Succesfully connected to target: " + str(session.resource.name))
        print("Available Software feeds:")
        for software_feed in session.get_software_feeds():
            print("\t"+str(software_feed))
        print("Installed Software:")
        print("\t Software Title\tVersion")
        for software in session.get_installed_software_components():
            print("\t" + str(software.title) + "\t" + str(software.version))
        print("Closing Session")
        session.close()

I get this response on Windows:

        SoftwareFeed(name='NI-dist', uri='http://download.ni.com/ni-linux-rt/feeds/dist', enabled=True, trusted=False)
        SoftwareFeed(name='ni-labview-2019', uri='http://download.ni.com/ni-linux-rt/feeds/2021.3/ni-lv2019', enabled=False, trusted=False)
        SoftwareFeed(name='ni-labview-2020', uri='http://download.ni.com/ni-linux-rt/feeds/2021.3/ni-lv2020', enabled=True, trusted=False)
        SoftwareFeed(name='ni-labview-2021', uri='http://download.ni.com/ni-linux-rt/feeds/2021.3/ni-lv2021', enabled=False, trusted=False)
        SoftwareFeed(name='ni-labview-nxg-5.1', uri='http://download.ni.com/ni-linux-rt/feeds/2021.3/ni-lvnxg50', enabled=False, trusted=False)
        SoftwareFeed(name='ni-software', uri='http://download.ni.com/ni-linux-rt/feeds/2021.3/ni-main', enabled=True, trusted=False)
        SoftwareFeed(name='ni-third-party', uri='http://download.ni.com/ni-linux-rt/feeds/2021.3/ni-third-party', enabled=False, trusted=False)
        ...etc

Installed Software:
         Software Title Version
        CompactRIO Support      21.0.0.49153-0+f1
        LabVIEW Real-Time       20.0.1.49159-0+f7
        Network Variable Engine 21.0.0.49350-0+f198
        NI Scan Engine  9.0.0.49152-0+f0
        NI System Configuration 21.0.0.49154-0+f2
        NI System Configuration Remote Support  21.0.0.49153-0+f1
        NI Web-Based Configuration and Monitoring       21.0.0.49733-0+f581
        NI-DAQmx        21.3.0.49319-0+f167
        NI-DAQmx OPC Server     21.3.0.49315-0+f163`
        ...etc

However, I am getting some errors in Ubuntu when using the same code:

Trying to connect to target: 10.34.9.29
Succesfully connected to target: NI-cRIO-9049-01D483E9
Available Software feeds:
    SAME RESPONSE AS ABOVE
Installed Software:
     Software Title Version
free(): invalid pointer
Aborted (core dumped)

Any ideas? Thanks in advance for your help!

tkrebes commented 1 year ago

I was able to identify and fix issue with get_installed_software_components #40. The fix is available for download with nisyscfg 0.0.5. With 0.0.5, the sample code provided in the original post worked for me on a Ubuntu 20.04 system.

However, the free(): invalid pointer seems to be an issue with python 3.8 overflowing its stack. I'd recommend using Python 3.9 on Ubuntu 20.04. I was about to reproduce the crash by creating a session and trying to access a non-existent property:

Python 3.8

> python
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nisyscfg
>>> session = nisyscfg.Session()
>>> session.not_a_property
free(): invalid pointer
Aborted (core dumped)

Python 3.9

> python3.9
Python 3.9.5 (default, Nov 23 2021, 15:27:38)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nisyscfg
>>> session = nisyscfg.Session()
>>> session.not_a_property
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Session' object has no attribute 'not_a_property'
tkrebes commented 1 year ago

I assume the work-around was sufficient. If this continues to be an issue, we can re-open it.

rscd27p commented 1 year ago

I @tkrebes, I was unable to fix it with 3.9. Thanks for your help!

tkrebes commented 1 year ago

@rscd27p, do you see the same error on with Python 3.9?

free(): invalid pointer
Aborted (core dumped)

Or, do you get a different error message?

tkrebes commented 1 year ago

By the way, the free(): invalid pointer issue in Python 3.8 seems to be fixed when using the latest software: