[Python] Error calling initializeNative: exception: access violation reading 0x0000000000000068

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    I have a buffer_array of ctype.POINTER that the object changes but the address is the same.

    I used an enumeration loop several times back to back and the object changes every time and the address is the same. I store the byte values in a separate object hoping that the object would persist.

    __declspec(dllexport) long long initializeNative(int lines, void* buffers, int numAngles, int* bufferSizes) {
    static int iViewHeight[sentinelVolumeEngine_MaximumNumberOfScanPlanes];
    static imiUInt16* pData[sentinelVolumeEngine_MaximumNumberOfScanPlanes][sentinelVolumeEngine_MaximumNumberOfEnergyLevels];

    // Process buffers and bufferSizes
    for (int i = 0; i < numAngles; i++) {
    iViewHeight = bufferSizes / lines;
    pData[0] = ((imiUInt16**)buffers); // Assuming buffers is an array of pointers
    }


    ..................

    data_buffer = memoryview(bytearray([0x01, 0x02, 0x03, 0x04])) buffers = [[data_buffer]]

    value = int.from_bytes(first_buffer[start:end], byteorder='little', signed=False) ctypes_buffer[line * height + channel] = value

    Retain reference to prevent garbage collection


    ctypes_buffers.append(ctypes_buffer)

    Assign pointer to buffer_pointers_array


    buffer_pointers_array = ctypes.cast(ctypes.addressof(ctypes_buffers[-1]), ctypes.POINTER(ctypes.c_uint16)) logger.debug(f"Buffer[{i}]: Address = {ctypes.addressof(ctypes_buffer)}, Size = {buffer_sizes}, Object = {ctypes_buffer}") Debug output: logger.debug(f"Buffer[{i}]: Address = {ctypes.addressof(ctypes_buffer)}, Size = {buffer_sizes}, Object = {ctypes_buffer}") Buffer[0]: Address = 1622983936624, Size = 8, Object = <vmengine.c_ushort_Array_4 **object at **0x00000179E19754D0>

    for i, ptr in enumerate(buffer_pointers_array): logger.debug(f"FIRST Buffer pointer[{i}]: {ptr}, Address: {ctypes.addressof(ptr.contents)}")
    Buffer pointer[0]: <ctypes.wintypes.LP_c_ushort object at 0x00000179E1975550>, Address: 1622983936624

    Error calling initializeNative: exception: access violation reading 0x0000000000000068

    Continue reading...

Compartilhe esta Página