-
Notifications
You must be signed in to change notification settings - Fork 145
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
python -m sounddevice crashes the python.exe process #256
Comments
Thanks for the report! Can you please run the following code and tell me what happens? from cffi import FFI
ffi = FFI()
lib = ffi.dlopen(None)
print(lib) |
No crash during this test. However, I've noticed that |
Thanks for the test! Since that didn't expose the error, we'll have to dig deeper. Can you please run the following code (which now uses import _cffi_backend
ffi = _cffi_backend.FFI('_dummy',
_version = 0x2601,
_types = b'\x00\x00\x05\x0D\x00\x00\x08\x03\x00\x00\x01\x11\x00\x00\x00\x0F\x00\x00\x09\x0D\x00\x00\x07\x03\x00\x00\x00\x0F\x00\x00\x00\x09\x00\x00\x02\x01\x00\x00\x07\x01',
_globals = (b'\x00\x00\x05\x21__stderrp',0,b'\x00\x00\x04\x23fclose',0,b'\x00\x00\x00\x23fopen',0,b'\x00\x00\x05\x21stderr',0),
_struct_unions = ((b'\x00\x00\x00\x07\x00\x00\x00\x10_IO_FILE',),),
_typenames = (b'\x00\x00\x00\x07FILE',),
)
stdio = ffi.dlopen(None)
print(stdio) |
Crashes in the exact same way. |
Great, now we have a much smaller test case! Maybe we can reduce it even more: import _cffi_backend
ffi = _cffi_backend.FFI()
stdio = ffi.dlopen(None)
print(stdio) What does this do? What if you replace What if you replace it by the empty string? What version of CFFI are you using? Can you upgrade CFFI (latest release is 1.14.0)? |
Example above using None still crashes. Nonsensical inputs return "OSError: cannot load library" as expected. Seems to be the problem with loading the C standard library or maybe any actual library that is found (at least judging from looking at the cffi/api.py which i assume this is a binary precompiled version of - haven't looked into how this works yet). |
I'm already on the latest version of cffi. |
This is interesting from the cffi documentation: |
It's interesting though, that dlopen(None) actually works when you use the scripting api directly, but not when you go via this precompiled backend or whatever this is meant to be. Either way looks like you might need a workaround at the very least for python 3, as according to the documentation it's not supposed to work anyway. |
I know that Pure Python code should never crash, so there must be a bug somewhere, probably in CFFI or in one of its dependencies. I've asked about this on the CFFI mailing list: https://groups.google.com/g/python-cffi/c/5DgTyV0DAas In the meantime, you could try whether the crash also happens with older CFFI versions. |
Of course pure python code should not crash the interpreter, but in this case we are not dealing with a pure python code, we are dealing with a precompiled dll (_cffi_backend.pyd) so it is completely reasonable that it might crash the interpreter. In this case it must be either A) a bug the precompiled code or B) a binary incompatibility between the precompiled code and my system. The suggestion in the mailing list reply seems reasonable - I've seen NULL pointer into "%s" crash before. On a side note, if you know that dlopen(None) is not supposed to work on windows, but sounddevice still calls it, then clearly it is expected to do nothing and another workaround would be to simply not call it on windows. Assuming this, I've replaced the line with |
For what it's worth, I get
But it makes sense to just add a check to bypass that path if it is not supposed to work on windows. |
Here's Armin's answer from the mailing list:
The check he mentioned is here: https://foss.heptapod.net/pypy/cffi/-/commit/0c0a5c48f034a3bc191563c2d504f0a8d66797a4 |
@mgeier Fair enough. Thanks for the heads up, and for the great package. |
A few weeks ago it was working well to me, then now is coming out this issue. The significant change I had since then.. I opted -in to Windows Insider's builds, which upgrades the windows version. |
There is no exception our backtrace in the output, just the standard window dialog pop-up "python.exe has stopped working".
I've narrowed it down to sounddevice.py:2731
stdio = _ffi.dlopen(None)
I tried this both with python 2.7 as well as 3.7 (both 64-bit).
Running on Windows 10 64-bit.
The text was updated successfully, but these errors were encountered: