dlopen(None) crashes CPython on Win 10 (out-of-line ABI mode)

28 views
Skip to first unread message

Matthias Geier

unread,
Jul 6, 2020, 2:49:25 PM7/6/20
to pytho...@googlegroups.com
Dear list.

I have received a bug report for my PortAudio wrapper which uses CFFI:
https://github.com/spatialaudio/python-sounddevice/issues/256.

The issue has been reduced to this minimal example:

#########################

import _cffi_backend
ffi = _cffi_backend.FFI()
lib = ffi.dlopen(None)
print(lib)

#########################

Running this code crashes the CPython interpreter on Windows 10.

I know that "ffi.dlopen(None)" is not supposed to work on Windows, but
it shouldn't crash the interpreter, right?

I would expect an exception to be thrown in this case.

Some more informations:

CPython 2.7 as well as 3.7 (both 64-bit).
Running on Windows 10 64-bit.
CFFI 1.14.0

cheers,
Matthias

Armin Rigo

unread,
Jul 6, 2020, 3:33:43 PM7/6/20
to pytho...@googlegroups.com
Hi Matthias,

On Mon, 6 Jul 2020 at 20:49, Matthias Geier <matthia...@gmail.com> wrote:
> #########################
>
> import _cffi_backend
> ffi = _cffi_backend.FFI()
> lib = ffi.dlopen(None)
> print(lib)
>
> #########################
>
> Running this code crashes the CPython interpreter on Windows 10.

Thanks, I've added some explicit checks. Note that I couldn't
reproduce on my Windows 10 machine, where it ends with a clean OSError
but with a somewhat obscure error message. Maybe the difference is
that I tried with a version compiled on my own, and the automatic
builders make a version that is linked with a different libc. The
error message is formatted with "%s" but in this case the pointer is
NULL. Maybe that causes only some of the versions of libc to crash...
Anyway, I've added a check and complain explicitly now before even
trying to call the Windows LoadLibrary() API.


A bientôt,

Armin.

Matthias Geier

unread,
Jul 7, 2020, 6:13:47 AM7/7/20
to pytho...@googlegroups.com
Hi Armin.

Thanks a lot for the very quick fix!

Are there already plans for when the next release will be?

cheers,
Matthias
> --
> -- python-cffi: To unsubscribe from this group, send email to python-cffi...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/python-cffi?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "python-cffi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to python-cffi...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/python-cffi/CAMSv6X3zi2L3b3NBhSRcAmJAxzCJPE2rqJ%2BQnv2S-ja88JHzGg%40mail.gmail.com.

Armin Rigo

unread,
Jul 10, 2020, 12:21:29 PM7/10/20
to pytho...@googlegroups.com
Hi, 


On Tue, 07 Jul 2020, 12:13 PM Matthias Geier <matthia...@gmail.com> wrote:
Thanks a lot for the very quick fix!

Are there already plans for when the next release will be?

No, but there are fixes being contributed right now (notably for OS X on aarch64) so I guess soon. 

Armin   
Reply all
Reply to author
Forward
0 new messages