old-style callback not working on Windows 11

21 views
Skip to first unread message

jm

unread,
Oct 9, 2024, 3:40:19 AM10/9/24
to python-cffi
Hi all,

I've a suite of python packages using cffi to tap into precompiled libraries. A colleague reported a process crash running on a Win11 box. A similar or identical setup on Win server 2019 (I think) worked, and I've no issue running on a Linux Debian. on Windows 11 users may see the error message "Process finished with exit code -1073741819 (0xC0000005)" (I could not). Looking further into it it seems the use of the old style `ffi.callback` is the likely cause of the issue. 

Two purposes for the present email: first a record for others bumping into similar issues, and second to get advice on working around the issue. I think I need to migrate to the new-style `@ffi.def_extern()` , but I don't trust my understanding of the ABI/API in/out of line matrix and would welcome a more expert opinion.

Details are in  csiro-hydroinformatics/uchronia-time-series/issues/1 ; in a nutshell the line that fails is:

```python
# uchronia_so is an FFI object
uchronia_so.RegisterExceptionCallback(_exception_callback_uchronia)
```
where:
```python
@uchronia_ffi.callback("void(char *)")
def _exception_callback_uchronia(exception_string):
    # etc
```

Any comment appreciated.

jm

unread,
Oct 17, 2024, 3:14:23 AM10/17/24
to python-cffi
I've diagnosed further the issue. Still not sure whether the old callback style function plays a role. The crash happens within the native DLL when trying to register the callback function. The same callback registration initiated from R into the very same DLL works though. Mystifying bug. https://github.com/csiro-hydroinformatics/moirai/issues/1  .  I will update this thread later I hope with a definitive answer about whether or nor this is an issue that can possibly arise for cffi users.
Reply all
Reply to author
Forward
0 new messages