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

OSError: exception: access violation reading 0x0000000000000008 #46

Open
lunarspectrum opened this issue Jun 10, 2024 · 6 comments
Open

Comments

@lunarspectrum
Copy link

lunarspectrum commented Jun 10, 2024

Description

OSError: exception: access violation reading 0x0000000000000008 occurs when trying to load a simple bitfile.

System Info

python 3.12.3 (64-bit, via miniconda)
nifpga 22.0.0

Windows 10 (64 bit)
NI USB-7845R
NI R Series Multifunction RIO Software version 18.5

Steps to reproduce

Using a simple example bitfile that runs using LabView, run

from nifpga import Session
with Session(bitfile=r"my_simple_bitfile.lvbitx", resource="RIO0") as session:
    session.reset()
    session.run()

Output

Traceback (most recent call last):
  File "test_nifpga.py", line 3, in <module>
    with Session(
         ^^^^^^^^
  File "<environment path>\Lib\site-packages\nifpga\session.py", line 118, in __init__
    self._nifpga.Open(bitfile_path,
  File "<environment path>\Lib\site-packages\nifpga\status.py", line 99, in internal
    status = function(*args)
             ^^^^^^^^^^^^^^^
OSError: exception: access violation reading 0x0000000000000008

Steps taken to resolve

Reinstalled and updated python from earlier version (was 3.10.x). Repaired NI installation. Contacted IT to verify that security software is not blocking access to the DLLs. Tried a different bitfile that runs in LabView. Reviewed this NI KB article.

@strainmike
Copy link
Collaborator

Just to confirm, it sounds like Python 3.10.x works for you, but upgrading to Python 3.12.x was broken? Or am I reading that wrong?

@lunarspectrum
Copy link
Author

No. It does not work under either version I have tried. I initially encountered the error in 3.10.

@strainmike
Copy link
Collaborator

Our ATS currently runs with Python 3.9, but I manually ran it with 3.12 and couldn't reproduce any issues.

I hadn't ever seen that KB before but clearly someone has run into this problem before. I can't find any internal docs about it though.

Could you try running something similar to the following to try to narrow down the issue:

import ctypes

bitfile = "my_simple_bitfile.lvbitx"
resource = "RIO0"

nifpga = ctypes.CDLL('NiFpga.dll')

nifpga.NiFpgaDll_Open.argtypes = [
    ctypes.POINTER(ctypes.c_char),  # bitfile
    ctypes.POINTER(ctypes.c_char),  # signature
    ctypes.POINTER(ctypes.c_char),  # resource
    ctypes.c_uint32,                # attribute
    ctypes.POINTER(ctypes.c_uint32) # session
]

nifpga.NiFpgaDll_Open.restype = ctypes.c_int32

def open_session(bitfile, resource):
    session = ctypes.c_uint32()
    result = nifpga.NiFpgaDll_Open(
        ctypes.c_char_p(bitfile.encode('utf-8')),
        None,
        ctypes.c_char_p(resource.encode('utf-8')),
        ctypes.c_uint32(1 << 31),
        session
    )
    return result, session.value
    
print(open_session(bitfile, resource))

This should succeed and isn't doing anything too special or nifpga specific. If that fails, you might try some very basic CDLL calls.

Note, I'm about to be OOO for a few weeks. If you need support before then you will probably need to open a ticket on https://www.ni.com/en/support.html

@lunarspectrum
Copy link
Author

Hi! Thanks for the quick response. Alas, this gives the same error message.

Also code that does not require a bitfile:

import ctypes
import nifpga
lib = nifpga.nifpga._NiFpga()
resourceIndex = ctypes.c_uint32()
resourceName = ctypes.c_char_p(b"RIO0")
lib.GetResourceIndex(resourceName,ctypes.byref(resourceIndex))

also gives

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Cell In[8], line 1
----> 1 lib.GetResourceIndex(resourceName,ctypes.byref(resourceIndex))

File <environment path>\Lib\site-packages\nifpga\status.py:99, in check_status.<locals>.decorator.<locals>.internal(*args)
     96 if hasattr(function, "argtypes") and len(args) != len(function.argtypes):
     97     raise TypeError("%s takes exactly %u arguments (%u given)"
     98                     % (function_name, len(function.argtypes), len(args)))
---> 99 status = function(*args)
    100 _raise_or_warn_if_nonzero_status(status, function_name, argument_names, args)

OSError: exception: access violation reading 0x0000000000000008

I've also updated the fpga dll to 19.0.0.49152, which has the same results.

I will contact support. Thank you again.

@lunarspectrum
Copy link
Author

Ok, I've got this and the original code working under python 3.10.4, 32-bit. I would really like to get this to work under a non-deprecated version. I've been in contact w/ support.

@lunarspectrum
Copy link
Author

lunarspectrum commented Jul 4, 2024

@strainmike, I'm now using a new computer with a fresh installation of everything. Still getting the same error message.

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