pleiszenburg / zugbruecke

Calling routines in Windows DLLs from Python scripts running under Linux, MacOS or BSD
https://zugbruecke.readthedocs.io/en/latest/
GNU Lesser General Public License v2.1
112 stars 11 forks source link

Passing custom types (enums) by value #104

Closed EclipsedButter closed 1 month ago

EclipsedButter commented 1 month ago

It seems as though custom groups haven't been fully implemented. I don't know very much about DLLs, and it's not my addon here, so I'm just going to put this here for recording's sake. I don't mean to code dump, but I intend to be thorough about this. I'm implementing zugbruecke in Blender (though I think that part is irrelevant at this point), in an addon that depends on the Oodle oo2core_6_win64.dll for file compression and decompression, and have encountered this problem. The DLL is loaded with the following:

__DLL = c.WinDLL(dll_path)

__DLL_Compress = __DLL["OodleLZ_Compress"]
__DLL_Compress.restype = c.c_long
__DLL_Compress.argtypes = (
    Compressor,  # compressor
    c.POINTER(c.c_char),  # rawBuf
    c.c_long,  # rawLen
    c.POINTER(c.c_char),  # compBuf
    CompressionLevel,  # level
    c.POINTER(CompressOptions),  # pOptions
    c.c_void_p,  # dictionaryBase
    c.c_void_p,  # lrm
    c.c_void_p,  # scratchMem
    c.c_long,  # scratchSize
)

__DLL_CompressOptions_GetDefault = __DLL["OodleLZ_CompressOptions_GetDefault"]
__DLL_CompressOptions_GetDefault.restype = c.POINTER(CompressOptions)
__DLL_CompressOptions_GetDefault.argtypes = (
    Compressor,  # compressor
    CompressionLevel,  # lzLevel
)

__DLL_Decompress = __DLL["OodleLZ_Decompress"]
__DLL_Decompress.restype = c.c_long
__DLL_Decompress.argtypes = (
    c.POINTER(c.c_char),  # compBuf
    c.c_long,  # compBufSize
    c.POINTER(c.c_char),  # rawBuf
    c.c_long,  # rawLen (known uncompressed size)
    c.c_int,  # fuzzSafe
    CheckCRC,  # checkCRC
    Verbosity,  # verbosity
    c.c_void_p,  # decBufBase
    c.c_long,  # decBufSize
    c.c_void_p,  # fpCallback
    c.c_void_p,  # callbackUserData
    c.c_void_p,  # decoderMemory
    c.c_long,  # decoderMemorySize
    c.c_int,  # threadPhase
)

__DLL_GetCompressedBufferSizeNeeded = __DLL["OodleLZ_GetCompressedBufferSizeNeeded"]
__DLL_GetCompressedBufferSizeNeeded.restype = c.c_long
__DLL_GetCompressedBufferSizeNeeded.argtypes = (
    c.c_long,  # rawSize
)

__DLL_GetDecodeBufferSize = __DLL["OodleLZ_GetDecodeBufferSize"]
__DLL_GetDecodeBufferSize.restype = c.c_long
__DLL_GetDecodeBufferSize.argtypes = (
    c.c_long,  # rawSize
    c.c_bool,  # corruptionPossible
)

Then attempt decompression of a file using the DLL, where comp_buf is the size of the compressed file in bytes and decompressed_size the expected size of the decompressed file according to a header, as an int.

comp_buf_size = len(comp_buf)
# noinspection PyCallingNonCallable,PyTypeChecker
comp_buf_array = (c.c_char * comp_buf_size)(*comp_buf)
max_raw_buf_size = __DLL_GetDecodeBufferSize(decompressed_size, True)
raw_buf_array = (c.c_char * max_raw_buf_size)()

actual_raw_buf_size = __DLL_Decompress(
    comp_buf_array,
    comp_buf_size,
    raw_buf_array,
    decompressed_size,
    FuzzSafe.Yes, # 1
    CheckCRC.No, # 0
    Verbosity.Null, # 0
    c.c_void_p(),
    0,
    c.c_void_p(),
    c.c_void_p(),
    c.c_void_p(),
    0,
    DecodeThreadPhase.Unthreaded,
)

This causes the error with the following traceback:

File "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oodle.py", line 328, in decompress
  actual_raw_buf_size = __DLL_Decompress(
                          ^^^^^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/routine_client.py", line 112, in __call__
  self._configure()
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/routine_client.py", line 220, in _configure
  _ = self._configure_on_server(
      ^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/rpc.py", line 74, in call_rpc_server
  raise result
ValueError: unknown group "Custom"

Accompanied by the log:

{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929738.84, "pipe": "out", "cnt": "[interpreter] Started with PID 9287."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929738.84, "pipe": "out", "cnt": "[interpreter] Starting stream reader threads ..."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929738.84, "pipe": "out", "cnt": "[interpreter] Stream reader threads started."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929738.84, "pipe": "out", "cnt": "[interpreter] Starting log processing thread ..."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929738.84, "pipe": "out", "cnt": "[interpreter] Log processing thread started."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929738.84, "pipe": "out", "cnt": "[interpreter] STARTED."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929738.84, "pipe": "out", "cnt": "[session-client] Waiting for session-server to be up ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.47, "pipe": "out", "cnt": "[session-server] STARTING ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.48, "pipe": "out", "cnt": "[rpc-server] STARTING ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.48, "pipe": "out", "cnt": "[rpc-server] Log attached."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.48, "pipe": "out", "cnt": "[rpc-server] STARTED."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.48, "pipe": "out", "cnt": "[session-server] ctypes server is listening on port 51792."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.48, "pipe": "out", "cnt": "[session-server] STARTED."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.48, "pipe": "out", "cnt": "[session-server] Serve forever ..."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.49, "pipe": "out", "cnt": "[session-client] ... session server is up (after 0.65 seconds)."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.5, "pipe": "out", "cnt": "[session-client] STARTED."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.5, "pipe": "out", "cnt": "[session-client] Attaching to DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" with calling convention \"windll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.5, "pipe": "out", "cnt": "[session-server] Attaching to DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" with calling convention \"windll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.5, "pipe": "out", "cnt": "[session-server] ... attached."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.5, "pipe": "out", "cnt": "[session-client] ... attached."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.5, "pipe": "out", "cnt": "[dll-client] Trying to register routine \"OodleLZ_Compress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.5, "pipe": "out", "cnt": "[dll-server] Trying to access \"OodleLZ_Compress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-client] ... registered (unconfigured)."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-client] Trying to register routine \"OodleLZ_CompressOptions_GetDefault\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-server] Trying to access \"OodleLZ_CompressOptions_GetDefault\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-client] ... registered (unconfigured)."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-client] Trying to register routine \"OodleLZ_Decompress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-server] Trying to access \"OodleLZ_Decompress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-client] ... registered (unconfigured)."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-client] Trying to register routine \"OodleLZ_GetCompressedBufferSizeNeeded\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-server] Trying to access \"OodleLZ_GetCompressedBufferSizeNeeded\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-client] ... registered (unconfigured)."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-client] Trying to register routine \"OodleLZ_GetDecodeBufferSize\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-server] Trying to access \"OodleLZ_GetDecodeBufferSize\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929739.51, "pipe": "out", "cnt": "[dll-client] ... registered (unconfigured)."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929811.98, "pipe": "out", "cnt": "[routine-client] Trying to call routine \"OodleLZ_GetDecodeBufferSize\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929811.98, "pipe": "out", "cnt": "[routine-client] ... has not been called before. Configuring ..."}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929811.98, "pipe": "out", "cnt": "{'argtypes': [<Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929811.98, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_bool flags=[]>],"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929811.98, "pipe": "out", "cnt": " 'argtypes_raw': [<class 'ctypes.c_long'>, <class 'ctypes.c_bool'>],"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929811.98, "pipe": "out", "cnt": " 'memsync': [],"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929811.98, "pipe": "out", "cnt": " 'memsync_raw': [],"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929811.98, "pipe": "out", "cnt": " 'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929811.98, "pipe": "out", "cnt": " 'restype_raw': <class 'ctypes.c_long'>}"}
{"level": 10, "platform": "WINE", "id": "b38af9b3", "time": 1725929811.99, "pipe": "out", "cnt": "{'argtypes': [<Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "b38af9b3", "time": 1725929811.99, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_bool flags=[]>],"}
{"level": 10, "platform": "WINE", "id": "b38af9b3", "time": 1725929811.99, "pipe": "out", "cnt": " 'argtypes_raw': [<class 'ctypes.c_longlong'>, <class 'ctypes.c_bool'>],"}
{"level": 10, "platform": "WINE", "id": "b38af9b3", "time": 1725929811.99, "pipe": "out", "cnt": " 'memsync': [],"}
{"level": 10, "platform": "WINE", "id": "b38af9b3", "time": 1725929811.99, "pipe": "out", "cnt": " 'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "b38af9b3", "time": 1725929811.99, "pipe": "out", "cnt": " 'restype_raw': <class 'ctypes.c_longlong'>}"}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-client] ... configured. Proceeding ..."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-client] ... packing and pushing args to server ..."}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "{'args': [4708872, True], 'packed_args': [4708872, True], 'packed_mempkgs': []}"}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-server] Trying to call routine \"OodleLZ_GetDecodeBufferSize\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-client] ... received feedback from server, unpacking & syncing arguments ..."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-client] ... unpacking return value ..."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-client] ... overwriting memory ..."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-client] ... everything unpacked and overwritten ..."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-client] ... return."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-client] Trying to call routine \"OodleLZ_Decompress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "[routine-client] ... has not been called before. Configuring ..."}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "{'argtypes': [<Definition group=PyCSimpleType field=None type=c_char flags=[-1]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_char flags=[-1]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=Custom field=None type=CheckCRC flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=Custom field=None type=Verbosity flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>],"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": " 'argtypes_raw': [<class 'ctypes.LP_c_char'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.c_long'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.LP_c_char'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.c_long'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.c_int'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <enum 'CheckCRC'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <enum 'Verbosity'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.c_long'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.c_long'>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": "                  <class 'ctypes.c_int'>],"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": " 'memsync': [],"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": " 'memsync_raw': [],"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": " 'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "b38af9b3", "time": 1725929812.0, "pipe": "out", "cnt": " 'restype_raw': <class 'ctypes.c_long'>}"}
{"level": 40, "platform": "WINE", "id": "b38af9b3", "time": 1725929812.01, "pipe": "err", "cnt": "Traceback (most recent call last):"}
{"level": 40, "platform": "WINE", "id": "b38af9b3", "time": 1725929812.01, "pipe": "err", "cnt": "  File \"C:\\python-3.7.4.stable\\lib\\site-packages\\zugbruecke\\core\\routine_server.py\", line 161, in configure"}
{"level": 40, "platform": "WINE", "id": "b38af9b3", "time": 1725929812.01, "pipe": "err", "cnt": "    for packed_argtype in packed_argtypes"}
{"level": 40, "platform": "WINE", "id": "b38af9b3", "time": 1725929812.01, "pipe": "err", "cnt": "  File \"C:\\python-3.7.4.stable\\lib\\site-packages\\zugbruecke\\core\\routine_server.py\", line 161, in <listcomp>"}
{"level": 40, "platform": "WINE", "id": "b38af9b3", "time": 1725929812.01, "pipe": "err", "cnt": "    for packed_argtype in packed_argtypes"}
{"level": 40, "platform": "WINE", "id": "b38af9b3", "time": 1725929812.01, "pipe": "err", "cnt": "  File \"C:\\python-3.7.4.stable\\lib\\site-packages\\zugbruecke\\core\\definitions\\base.py\", line 231, in from_packed"}
{"level": 40, "platform": "WINE", "id": "b38af9b3", "time": 1725929812.01, "pipe": "err", "cnt": "    raise ValueError(f'unknown group \"{group}\"')  # TODO new error type?"}
{"level": 40, "platform": "WINE", "id": "b38af9b3", "time": 1725929812.01, "pipe": "err", "cnt": "ValueError: unknown group \"Custom\""}

I looked into it, and noticed that the DefinitionCustom class wasn't referenced in Definition.from_packed, so I threw a stone out, imported it, and put down

if group == DefinitionCustom.GROUP:
    return DefinitionCustom.from_packed(**packed)

I assume that this definition wasn't implemented here for good reason, given that I got this error next:

File "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oodle.py", line 328, in decompress
  actual_raw_buf_size = __DLL_Decompress(
                        ^^^^^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/routine_client.py", line 131, in __call__
  return_package = self._call_on_server(packed_args, packed_mempkgs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/rpc.py", line 74, in call_rpc_server
  raise result
TypeError: one character bytes, bytearray or integer expected

with the log:

{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934123.69, "pipe": "out", "cnt": "[interpreter] Started with PID 9595."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934123.69, "pipe": "out", "cnt": "[interpreter] Starting stream reader threads ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934123.69, "pipe": "out", "cnt": "[interpreter] Stream reader threads started."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934123.69, "pipe": "out", "cnt": "[interpreter] Starting log processing thread ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934123.69, "pipe": "out", "cnt": "[interpreter] Log processing thread started."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934123.69, "pipe": "out", "cnt": "[interpreter] STARTED."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934123.69, "pipe": "out", "cnt": "[session-client] Waiting for session-server to be up ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.33, "pipe": "out", "cnt": "[session-server] STARTING ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.33, "pipe": "out", "cnt": "[rpc-server] STARTING ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.33, "pipe": "out", "cnt": "[rpc-server] Log attached."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.33, "pipe": "out", "cnt": "[rpc-server] STARTED."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.34, "pipe": "out", "cnt": "[session-server] ctypes server is listening on port 51902."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.34, "pipe": "out", "cnt": "[session-server] STARTED."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.34, "pipe": "out", "cnt": "[session-server] Serve forever ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.34, "pipe": "out", "cnt": "[session-client] ... session server is up (after 0.65 seconds)."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.34, "pipe": "out", "cnt": "[session-client] STARTED."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.34, "pipe": "out", "cnt": "[session-client] Attaching to DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" with calling convention \"windll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.34, "pipe": "out", "cnt": "[session-server] Attaching to DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" with calling convention \"windll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[session-server] ... attached."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[session-client] ... attached."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-client] Trying to register routine \"OodleLZ_Compress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-server] Trying to access \"OodleLZ_Compress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-client] ... registered (unconfigured)."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-client] Trying to register routine \"OodleLZ_CompressOptions_GetDefault\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-server] Trying to access \"OodleLZ_CompressOptions_GetDefault\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-client] ... registered (unconfigured)."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-client] Trying to register routine \"OodleLZ_Decompress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-server] Trying to access \"OodleLZ_Decompress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-client] ... registered (unconfigured)."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-client] Trying to register routine \"OodleLZ_GetCompressedBufferSizeNeeded\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-server] Trying to access \"OodleLZ_GetCompressedBufferSizeNeeded\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-client] ... registered (unconfigured)."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-client] Trying to register routine \"OodleLZ_GetDecodeBufferSize\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.35, "pipe": "out", "cnt": "[dll-server] Trying to access \"OodleLZ_GetDecodeBufferSize\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934124.36, "pipe": "out", "cnt": "[dll-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934124.36, "pipe": "out", "cnt": "[dll-client] ... registered (unconfigured)."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.13, "pipe": "out", "cnt": "[routine-client] Trying to call routine \"OodleLZ_GetDecodeBufferSize\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.13, "pipe": "out", "cnt": "[routine-client] ... has not been called before. Configuring ..."}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.13, "pipe": "out", "cnt": "{'argtypes': [<Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.13, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_bool flags=[]>],"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.13, "pipe": "out", "cnt": " 'argtypes_raw': [<class 'ctypes.c_long'>, <class 'ctypes.c_bool'>],"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.13, "pipe": "out", "cnt": " 'memsync': [],"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.13, "pipe": "out", "cnt": " 'memsync_raw': [],"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.13, "pipe": "out", "cnt": " 'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.13, "pipe": "out", "cnt": " 'restype_raw': <class 'ctypes.c_long'>}"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": "{'argtypes': [<Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_bool flags=[]>],"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": " 'argtypes_raw': [<class 'ctypes.c_longlong'>, <class 'ctypes.c_bool'>],"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": " 'memsync': [],"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": " 'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": " 'restype_raw': <class 'ctypes.c_longlong'>}"}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": "[routine-client] ... configured. Proceeding ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": "[routine-client] ... packing and pushing args to server ..."}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": "{'args': [4708872, True], 'packed_args': [4708872, True], 'packed_mempkgs': []}"}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": "[routine-server] Trying to call routine \"OodleLZ_GetDecodeBufferSize\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934136.14, "pipe": "out", "cnt": "[routine-server] ... done."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "[routine-client] ... received feedback from server, unpacking & syncing arguments ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "[routine-client] ... unpacking return value ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "[routine-client] ... overwriting memory ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "[routine-client] ... everything unpacked and overwritten ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "[routine-client] ... return."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "[routine-client] Trying to call routine \"OodleLZ_Decompress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "[routine-client] ... has not been called before. Configuring ..."}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "{'argtypes': [<Definition group=PyCSimpleType field=None type=c_char flags=[-1]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_char flags=[-1]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=Custom field=None type=CheckCRC flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=Custom field=None type=Verbosity flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>],"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": " 'argtypes_raw': [<class 'ctypes.LP_c_char'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_long'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.LP_c_char'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_long'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_int'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <enum 'CheckCRC'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <enum 'Verbosity'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_long'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_long'>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_int'>],"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": " 'memsync': [],"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": " 'memsync_raw': [],"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": " 'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": " 'restype_raw': <class 'ctypes.c_long'>}"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "{'argtypes': [<Definition group=PyCSimpleType field=None type=c_char flags=[-1]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_char flags=[-1]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=Custom field=None type=CheckCRC flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=Custom field=None type=Verbosity flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "              <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>],"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": " 'argtypes_raw': [<class 'ctypes.LP_c_char'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_longlong'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.LP_c_char'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_longlong'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_long'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_longlong'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_void_p'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_longlong'>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": "                  <class 'ctypes.c_long'>],"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": " 'memsync': [],"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": " 'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,"}
{"level": 10, "platform": "WINE", "id": "31efd070", "time": 1725934136.15, "pipe": "out", "cnt": " 'restype_raw': <class 'ctypes.c_longlong'>}"}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "[routine-client] ... configured. Proceeding ..."}
{"level": 20, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "[routine-client] ... packing and pushing args to server ..."}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "{'args': [<soulstruct.dcx.oodle.c_char_Array_2179722 object at 0x304ac4bd0>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          2179722,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          <soulstruct.dcx.oodle.c_char_Array_4709128 object at 0x34affd650>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          4708872,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          <FuzzSafe.Yes: 1>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          <CheckCRC.No: 0>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          <Verbosity.Null: 0>,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          c_void_p(None),"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          0,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          c_void_p(None),"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          c_void_p(None),"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          c_void_p(None),"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          0,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "          <DecodeThreadPhase.ThreadPhaseAll: 3>],"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": " 'packed_args': [b'\\x8c\\x06\\x01B\\x0e\\x80\\x99\\xe7BND4',"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 2179722,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 b'',"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 4708872,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 1,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 None,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 None,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 None,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 0,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 None,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 None,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 None,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 0,"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": "                 3],"}
{"level": 10, "platform": "UNIX", "id": "31efd070", "time": 1725934136.16, "pipe": "out", "cnt": " 'packed_mempkgs': []}"}
{"level": 20, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "out", "cnt": "[routine-server] Trying to call routine \"OodleLZ_Decompress\" in DLL file \"/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/ctypesAddon/oo2core_6_win64.dll\" ..."}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "[routine-server] ... call preparation failed!"}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "Traceback (most recent call last):"}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "  File \"C:\\python-3.7.4.stable\\lib\\site-packages\\zugbruecke\\core\\routine_server.py\", line 99, in call"}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "    packed_args, self._argtypes, self._convention"}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "  File \"C:\\python-3.7.4.stable\\lib\\site-packages\\zugbruecke\\core\\data.py\", line 133, in unpack_args"}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "    for arg, argtype in zip(args, argtypes)"}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "  File \"C:\\python-3.7.4.stable\\lib\\site-packages\\zugbruecke\\core\\data.py\", line 133, in <listcomp>"}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "    for arg, argtype in zip(args, argtypes)"}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "  File \"C:\\python-3.7.4.stable\\lib\\site-packages\\zugbruecke\\core\\data.py\", line 515, in _unpack_item"}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "    item = itemtype.base_type(item)"}
{"level": 40, "platform": "WINE", "id": "31efd070", "time": 1725934136.17, "pipe": "err", "cnt": "TypeError: one character bytes, bytearray or integer expected"}

At this point, this extends well past my understanding of ctypes and zugbruecke, so I can't figure out why DefinitionCustom doesn't work nor how to fix it; that, and the problem could be specific to this DLL, or maybe not. Regardless, I'll just leave this here so you know it's out there, and so maybe I can come back to it one day.

Credit to Scott Mooney for the Blender addon code displayed here

s-m-e commented 1 month ago

You're attempting to use custom types for certain parameters, e.g.

__DLL_Compress.argtypes = (
    Compressor,  # compressor
    c.POINTER(c.c_char),  # rawBuf
    c.c_long,  # rawLen
    c.POINTER(c.c_char),  # compBuf
    CompressionLevel,  # level
[...]

Compressor and CompressionLevel as well as c.POINTER(CompressOptions). How are those defined?

ctypes and zugbruecke can deal with custom, non-C types - if they have certain interfaces, usually prefixed with from_. Here is a full example of how this may look like.

EclipsedButter commented 1 month ago

I'll preface this by saying that this addon and its implementation of ctypes should work out of the box on windows. I don't know if that means that the module there has less stringent interfaces or not. Compressor and CompressionLevel implement CtypesEnum:

class CtypesEnum(IntEnum):
    """A ctypes-compatible IntEnum superclass."""
    @classmethod
    def from_param(cls, obj):
        return int(obj)
class Compressor(CtypesEnum):
    Invalid = -1
    Null = 3

    Kraken = 8
    Leviathan = 13
    Mermaid = 9
    Selkie = 11
    Hydra = 12

    BitKnit = 10
    LZB16 = 4
    LZNA = 7
    LZH = 0
    LZHLW = 1
    LZNIB = 2
    LZBLW = 5
    LZA = 6

    Count = 14
    Force32 = 0x40000000
class CompressionLevel(CtypesEnum):
    Null = 0
    SuperFast = 1
    VeryFast = 2
    Fast = 3
    Normal = 4

    Optimal1 = 5
    Optimal2 = 6
    Optimal3 = 7
    Optimal4 = 8
    Optimal5 = 9

    HyperFast1 = -1
    HyperFast2 = -2
    HyperFast3 = -3
    HyperFast4 = -4

    HyperFast = HyperFast1
    Optimal = Optimal2
    Max = Optimal5
    Min = HyperFast4

    Force32 = 0x40000000
    Invalid = Force32

CompressOptions implements c.Structure

class CompressOptions(c.Structure):
    _fields_ = [
        ("verbosity", c.c_uint),
        ("minMatchLen", c.c_int),
        ("seekChunkReset", c.c_bool),
        ("seekChunkLen", c.c_int),
        ("profile", c.c_int),  # `Profile`
        ("dictionarySize", c.c_int),
        ("spaceSpeedTradeoffBytes", c.c_int),
        ("maxHuffmansPerChunk", c.c_int),
        ("sendQuantumCRCs", c.c_bool),
        ("maxLocalDictionarySize", c.c_int),
        ("makeLongRangeMatcher", c.c_int),
        ("matchTableSizeLog2", c.c_int),
    ]

Though, I believe decompression is the only operation being called here, and it has far fewer custom types, all subclasses CTypesEnum:

class Verbosity(CtypesEnum):
    Null = 0
    Minimal = 1
    Some = 2
    Lots = 3
    Force32 = 0x40000000
class CheckCRC(CtypesEnum):
    No = 0
    Yes = 1
    Force32 = 0x40000000

So if my understanding is correct, all of the custom types implement no more than from_param.

s-m-e commented 1 month ago

We're getting closer ;) zugbruecke does not support Python's enums as transparently as ctypes does - yet. So yes, from_param is the one method that you'd need. It's thin ice though because I have not seen this being used in the wild, ever. It's only implemented in zugbruecke because an example in a classic piece of literature is using it. As long as you are passing a static value, you should be fine. If you want to alter the value, i.e. the DLL wants to write into memory passed as a pointer, you should work around by using integer types directly instead.

s-m-e commented 1 month ago

Last but not least, you need to make zugbruecke aware of the custom type (i.e. in your case stuff based on CtypesEnum) which is something that is not required with ctypes (on Windows in your case). The example I pointed to you earlier, here, uses a memsync directive, a feature of zugbruecke, to tell zugbruecke's typing system that there is a custom type coming its way.

EclipsedButter commented 1 month ago

So I put this after __DLL_Compress.argtypes

__DLL_Decompress.memsync = [
        dict(
            pointer = [5],  # "path" to argument containing the pointer
            length = 1,  # "path" to argument containing the length
            type = c.c_int,  # type of argument (optional, default char/byte): sizeof(type) * length == bytes
            custom = CheckCRC,  # custom datatype
        ),
        dict(
            pointer = [6],  # "path" to argument containing the pointer
            length = 1,  # "path" to argument containing the length
            type = c.c_int,  # type of argument (optional, default char/byte): sizeof(type) * length == bytes
            custom = Verbosity,  # custom datatype
        ),
        dict(
            pointer = [0],  # "path" to argument containing the pointer
            length = [1],  # "path" to argument containing the length
            type = c.c_char,  # type of argument (optional, default char/byte): sizeof(type) * length == bytes
        ),
        dict(
            pointer = [2],  # "path" to argument containing the pointer
            length = [3],  # "path" to argument containing the length
            type = c.c_char,  # type of argument (optional, default char/byte): sizeof(type) * length == bytes
        ),
    ]

Unfortunately, for the two custom types, I really have no idea what to put for length. argtypes isn't passed anything for the length of those two. I can get around it for a bit by replacing the custom types with c.c_int, but eventually the addon tries to write to the Enum and can't. Since it's a pointer to a single integer (e.g. CheckCRC.No is initialized as 0), I would assume the length would be 1 (and I think int in python is minimum 28 bytes). I get this traceback:

  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/routine_client.py", line 118, in __call__
    mempkgs = DefinitionMemsync.pkg_memories(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/definitions/memsync.py", line 626, in pkg_memories
    return [memsync.pkg_memory(args) for memsync in memsyncs]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/definitions/memsync.py", line 626, in <listcomp>
    return [memsync.pkg_memory(args) for memsync in memsyncs]
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/definitions/memsync.py", line 435, in pkg_memory
    ptr = ctypes.pointer(ptr)
          ^^^^^^^^^^^^^^^^^^^
TypeError: _type_ must have storage info

Which I assume is because I don't have a valid length argument.

s-m-e commented 1 month ago

You'd need to set the length to literally 1 which really is not supported yet. The other problem is that for custom types, zugbruecke assumes that they're passed as pointers, which they are not in your case. Hence zugbruecke tries to "recover" by wrapping them into pointers itself - which crashes. My code has a lovely "TODO" comment there ... I think this is fixable with manageable effort and I have enough information for a test case. Let me come back to you.

s-m-e commented 1 month ago

There are a number of lovely issues with enums in general such as this, which are hard to abstract away from users. I attempted to add support for them though. It's sitting in branch feature_enum. Please try.

A matching test case based upon your use case can be found here. Note that there is a new argument in memsync called value. It's a path similar to pointer. Setting a static length is achieved by providing an empty tuple for length and setting a length function simply to lambda: 1 (i.e. length 1). It's not straight forward but required the least changes to an already complicated code path.

The current solution is experimental, by all means. It might change as its design is ... questionable ;) Feedback is highly welcome.

EclipsedButter commented 1 month ago

Highly welcome (?) feedback incoming! So, this definitely got a lot closer... sort of :P

So, it successfully configures the decompression routine, and then writes 10,000 lines of bytes for packed_mempkgs.data (is there a logging level that would not do that?) to stdout, Wine calls the decompression routine, returns done., and then after receiving that, UNIX o: [routine-client] ... received feedback from server, unpacking & syncing arguments ..., and then we get this fun traceback:

oodle.py", line 354, in decompress
    actual_raw_buf_size = __DLL_Decompress(
                          ^^^^^^^^^^^^^^^^^
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/routine_client.py", line 136, in __call__
    self._data.sync_args(
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/data.py", line 212, in sync_args
    self._sync_arg(old_arg, new_arg, argtype)
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/data.py", line 398, in _sync_arg
    old_arg.value = new_arg.value
    ^^^^^^^^^^^^^
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/enum.py", line 215, in __set__
    raise AttributeError(
AttributeError: <enum 'Enum'> cannot set attribute 'value'

As it happens, I've actually gotten a very similar error on the exact same line before! I mentioned earlier that I tried replacing the enums with c_ints, and updating argtypes appropriately and putting in literals. This gets more or less the exact same log and traceback, but for that last line. In both cases, it looks like something (the routine I think) tries to write to the parameters for CheckCRC and Verbosity; when I just use c_int, it can't because that isn't a pointer, and with your new solution for enums, we get the above. Hope this helps :)

s-m-e commented 1 month ago

Have a close look at the test case. The error you see is caused by not passing the enum correctly. First, it must neither be configured nor passed as a pointer, though I guess this not the problem that you are seeing. Second, the memsync directive must be adjusted accordingly - otherwise you end up in the wrong code path with a failed sync like in your traceback. If you are not sure, can you share the configuration of your function (argtypes, restype and memsync) as well as the section of code where the function gets invoked?

EclipsedButter commented 1 month ago

Hm, I tried to match the test case as closely as I could. Here's what I have:

class CtypesEnum(IntEnum):
    @classmethod
    def from_param(cls, obj):
        return int(obj)

class CheckCRC(CtypesEnum):
    No = 0
    Yes = 1
    Force32 = 0x40000000

class Verbosity(CtypesEnum):
    Null = 0
    Minimal = 1
    Some = 2
    Lots = 3
    Force32 = 0x40000000

class DecodeThreadPhase(CtypesEnum):
    ThreadPhase1 = 1
    ThreadPhase2 = 2
    ThreadPhaseAll = 3
    Unthreaded = ThreadPhaseAll

__DLL_Decompress = __DLL["OodleLZ_Decompress"]
__DLL_Decompress.argtypes = (
    c.POINTER(c.c_char),  # compBuf
    c.c_long,  # compBufSize
    c.POINTER(c.c_char),  # rawBuf
    c.c_long,  # rawLen (known uncompressed size)
    c.c_int,  # fuzzSafe
    CheckCRC,  # checkCRC
    Verbosity,  # verbosity
    c.c_void_p,  # decBufBase
    c.c_long,  # decBufSize
    c.c_void_p,  # fpCallback
    c.c_void_p,  # callbackUserData
    c.c_void_p,  # decoderMemory
    c.c_long,  # decoderMemorySize
    c.c_int,  # threadPhase
)

__DLL_Decompress.restype = c.c_long
__DLL_Decompress.memsync = [
    dict(
        value = [5],
        length = tuple(),
        type = c.c_int, 
        custom = CheckCRC,
        func = "lambda: 1",
    ),
    dict(
        value = [6],
        length = tuple(),
        type = c.c_int,
        custom = Verbosity,
        func = "lambda: 1",
    ),
    dict(
        pointer = [0],
        length = [1], 
        type = c.c_char,
    ),
    dict(
        pointer = [2],
        length = [3],
        type = c.c_char,
    ),
]

actual_raw_buf_size = __DLL_Decompress(
        comp_buf_array,
        comp_buf_size,
        raw_buf_array,
        decompressed_size,
        FuzzSafe.Yes,
        CheckCRC.No,
        Verbosity.Null,
        c.c_void_p(),
        0,
        c.c_void_p(),
        c.c_void_p(),
        c.c_void_p(),
        0,
        DecodeThreadPhase.Unthreaded,
    )

Calling _DLL_Decompress is where the error occurs, and it specifies an issue with the enums, and since the only other enums, FuzzSafe and DecodeThreadPhase are passed by argtypes as c_int, I don't think they are causing the problem.

s-m-e commented 1 month ago

I just built a function with a similar signature and can not reproduce this. Can you activate full logging and post the log section for this function call?

EclipsedButter commented 1 month ago
(1726938898.55/46e4aad1)UNIX o: [dll-client] Trying to register routine "OodleLZ_Decompress" in DLL file "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/myAddon/oo2core_6_win64.dll" ...
(1726938898.55/46e4aad1)WINE o: [dll-server] Trying to access "OodleLZ_Decompress" in DLL file "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/myAddon/oo2core_6_win64.dll" ...
(1726938898.55/46e4aad1)WINE o: [dll-server] ... done.
(1726938898.55/46e4aad1)UNIX o: [dll-client] ... registered (unconfigured).
(1726938909.72/46e4aad1)UNIX o: [routine-client] Trying to call routine "OodleLZ_Decompress" in DLL file "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/myAddon/oo2core_6_win64.dll" ...
(1726938909.72/46e4aad1)UNIX o: [routine-client] ... has not been called before. Configuring ...
(1726938909.73/46e4aad1)UNIX o: {'argtypes': [<Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)UNIX o:               <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>],
(1726938909.73/46e4aad1)UNIX o:  'argtypes_raw': [<class 'ctypes.LP_c_char'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.LP_c_char'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.c_int'>,
(1726938909.73/46e4aad1)UNIX o:                   <enum 'CheckCRC'>,
(1726938909.73/46e4aad1)UNIX o:                   <enum 'Verbosity'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)UNIX o:                   <class 'ctypes.c_int'>],
(1726938909.73/46e4aad1)UNIX o:  'memsync': [<Memsync type=c_int null=False unic=False func=True>,
(1726938909.73/46e4aad1)UNIX o:              <Memsync type=c_int null=False unic=False func=True>,
(1726938909.73/46e4aad1)UNIX o:              <Memsync type=c_char null=False unic=False func=False>,
(1726938909.73/46e4aad1)UNIX o:              <Memsync type=c_char null=False unic=False func=False>],
(1726938909.73/46e4aad1)UNIX o:  'memsync_raw': [{'custom': <enum 'CheckCRC'>,
(1726938909.73/46e4aad1)UNIX o:                   'func': 'lambda: 1',
(1726938909.73/46e4aad1)UNIX o:                   'length': (),
(1726938909.73/46e4aad1)UNIX o:                   'type': 'c_int',
(1726938909.73/46e4aad1)UNIX o:                   'value': [5]},
(1726938909.73/46e4aad1)UNIX o:                  {'custom': <enum 'Verbosity'>,
(1726938909.73/46e4aad1)UNIX o:                   'func': 'lambda: 1',
(1726938909.73/46e4aad1)UNIX o:                   'length': (),
(1726938909.73/46e4aad1)UNIX o:                   'type': 'c_int',
(1726938909.73/46e4aad1)UNIX o:                   'value': [6]},
(1726938909.73/46e4aad1)UNIX o:                  {'length': [1], 'pointer': [0], 'type': 'c_char'},
(1726938909.73/46e4aad1)UNIX o:                  {'length': [3], 'pointer': [2], 'type': 'c_char'}],
(1726938909.73/46e4aad1)UNIX o:  'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)UNIX o:  'restype_raw': <class 'ctypes.c_long'>}
(1726938909.73/46e4aad1)WINE o: {'argtypes': [<Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)WINE o:               <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>],
(1726938909.73/46e4aad1)WINE o:  'argtypes_raw': [<class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_longlong'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_longlong'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_longlong'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_longlong'>,
(1726938909.73/46e4aad1)WINE o:                   <class 'ctypes.c_long'>],
(1726938909.73/46e4aad1)WINE o:  'memsync': [<Memsync type=c_int null=False unic=False func=True>,
(1726938909.73/46e4aad1)WINE o:              <Memsync type=c_int null=False unic=False func=True>,
(1726938909.73/46e4aad1)WINE o:              <Memsync type=c_char null=False unic=False func=False>,
(1726938909.73/46e4aad1)WINE o:              <Memsync type=c_char null=False unic=False func=False>],
(1726938909.73/46e4aad1)WINE o:  'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)WINE o:  'restype_raw': <class 'ctypes.c_longlong'>}
(1726938909.75/46e4aad1)UNIX o: [routine-client] ... configured. Proceeding ...
(1726938909.75/46e4aad1)UNIX o: [routine-client] ... packing and pushing args to server ...
(1726938911.55/46e4aad1)UNIX o: {'args': [<myAddon.oodle.c_char_Array_7110478 object at 0x34dd92150>,
(1726938911.55/46e4aad1)UNIX o:           7110478,
(1726938911.55/46e4aad1)UNIX o:           <myAddon.oodle.c_char_Array_15581048 object at 0x34dd915d0>,
(1726938911.55/46e4aad1)UNIX o:           15580792,
(1726938911.55/46e4aad1)UNIX o:           <FuzzSafe.Yes: 1>,
(1726938911.55/46e4aad1)UNIX o:           <CheckCRC.No: 0>,
(1726938911.55/46e4aad1)UNIX o:           <Verbosity.Null: 0>,
(1726938911.55/46e4aad1)UNIX o:           c_void_p(None),
(1726938911.55/46e4aad1)UNIX o:           0,
(1726938911.55/46e4aad1)UNIX o:           c_void_p(None),
(1726938911.55/46e4aad1)UNIX o:           c_void_p(None),
(1726938911.55/46e4aad1)UNIX o:           c_void_p(None),
(1726938911.55/46e4aad1)UNIX o:           0,
(1726938911.55/46e4aad1)UNIX o:           <DecodeThreadPhase.ThreadPhaseAll: 3>],
(1726938911.55/46e4aad1)UNIX o:  'packed_args': [None,
(1726938911.55/46e4aad1)UNIX o:                  7110478,
(1726938911.55/46e4aad1)UNIX o:                  None,
(1726938911.55/46e4aad1)UNIX o:                  15580792,
(1726938911.55/46e4aad1)UNIX o:                  1,
(1726938911.55/46e4aad1)UNIX o:                  0,
(1726938911.55/46e4aad1)UNIX o:                  0,
(1726938911.55/46e4aad1)UNIX o:                  None,
(1726938911.55/46e4aad1)UNIX o:                  0,
(1726938911.55/46e4aad1)UNIX o:                  None,
(1726938911.55/46e4aad1)UNIX o:                  None,
(1726938911.55/46e4aad1)UNIX o:                  None,
(1726938911.55/46e4aad1)UNIX o:                  0,
(1726938911.55/46e4aad1)UNIX o:                  3],
(1726938911.55/46e4aad1)UNIX o:  'packed_mempkgs': [{'byvalue': True,
(1726938911.55/46e4aad1)UNIX o:                      'data': b'\x00\x00\x00\x00',
(1726938911.55/46e4aad1)UNIX o:                      'local_addr': 14190979480,
(1726938911.55/46e4aad1)UNIX o:                      'remote_addr': None,
(1726938911.55/46e4aad1)UNIX o:                      'wchar': None},
(1726938911.55/46e4aad1)UNIX o:                     {'byvalue': True,
(1726938911.55/46e4aad1)UNIX o:                      'data': b'\x00\x00\x00\x00',
(1726938911.55/46e4aad1)UNIX o:                      'local_addr': 14190978584,
(1726938911.55/46e4aad1)UNIX o:                      'remote_addr': None,
(1726938911.55/46e4aad1)UNIX o:                      'wchar': None},
(1726938911.55/46e4aad1)UNIX o:                     {'byvalue': False,
(1726938911.55/46e4aad1)UNIX o:                      'data': <178714 lines>
(1726938911.55/46e4aad1)UNIX o:                      'local_addr': 14192115712,
(1726938911.55/46e4aad1)UNIX o:                      'remote_addr': None,
(1726938911.55/46e4aad1)UNIX o:                      'wchar': None}]}
(1726939091.43/46e4aad1)WINE o: [routine-server] Trying to call routine "OodleLZ_Decompress" in DLL file "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/myAddon/oo2core_6_win64.dll" ...
(1726939091.46/46e4aad1)WINE o: [routine-server] ... done.
(1726939091.51/46e4aad1)UNIX o: [routine-client] ... received feedback from server, unpacking & syncing arguments ...

  File "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/myAddon/oodle.py", line 354, in decompress
    actual_raw_buf_size = __DLL_Decompress(
                          ^^^^^^^^^^^^^^^^^
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/routine_client.py", line 136, in __call__
    self._data.sync_args(
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/data.py", line 212, in sync_args
    self._sync_arg(old_arg, new_arg, argtype)
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/data.py", line 398, in _sync_arg
    old_arg.value = new_arg.value
    ^^^^^^^^^^^^^
  File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/enum.py", line 215, in __set__
    raise AttributeError(
AttributeError: <enum 'Enum'> cannot set attribute 'value'
s-m-e commented 1 month ago

Thanks, I made a dumb mistake when trying to reproduce - now I get the same result.

As a temporary fix, in your function call, explicitly convert DecodeThreadPhase.Unthreaded to int i.e. pass int(DecodeThreadPhase.Unthreaded) to your function instead. This should do the trick. The sync code in zugbruecke needs a rework though to at least throw meaningful errors ...

EclipsedButter commented 1 month ago

Alas, same log, same traceback. I even tried replacing it with just a literal (3). At this point, it's probably an issue on my end...

EclipsedButter commented 1 month ago

Ahah, never mind :D I did some print debugging and noticed that it was throwing the error when evaluating FuzzSafe.Yes, which is in the same boat as DecodeThreadPhase.Unthreaded. It seems to be working now! I'll do some further testing and let you know if more custom type issues crop up. Thanks again!