python-samplerate icon indicating copy to clipboard operation
python-samplerate copied to clipboard

Illegal instruction: 4 thrown on darwin

Open mysyzygy opened this issue 7 years ago • 7 comments

Performing the following on specific mac computers throws an illegal instruction: 4 error and kills python running python 3.6.5, 3.6.3, and 3.5.4.

$ ipython In [1]: import samplerate In [2]: src = samplerate.Resampler('sinc_best', channels=1) Illegal instruction: 4

Occurs on: Model Identifier: MacPro6,1 Processor Name: Quad-Core Intel Xeon E5 macOS: 10.12.6 Darwin Kernel Version 16.7.0

$ pip list Package Version


cffi 1.11.5 numpy 1.14.5 pip 10.0.1 pycparser 2.18
samplerate 0.1.0
setuptools 39.0.1

mysyzygy avatar Jul 02 '18 22:07 mysyzygy

Interesting. I'll check the compiler options for the included binaries. In the meantime, you could install libsamplerate from Homebrew, and either replace the included binary (see here) or remove it (will fall back to the one installed on the system).

tuxu avatar Jul 03 '18 06:07 tuxu

Thanks tuxu, I'll give that a try and let you know.

mysyzygy avatar Jul 12 '18 17:07 mysyzygy

Yea, that build works thanks!

mysyzygy avatar Jul 12 '18 18:07 mysyzygy

I'm finding what looks like the same issue on my machine:

>>> import samplerate
>>> resampler = samplerate.Resampler('sinc_medium', channels=1)
Illegal instruction: 4

Machine details:

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.6
BuildVersion:	17G14042

$ python --version
Python 3.8.6

$ pip list
Package             Version
------------------- ---------
...
cffi                1.14.5
numpy               1.20.2
pip                 21.0.1
pycparser           2.20
samplerate          0.1.0
setuptools          49.2.1
...

CrepeGoat avatar Apr 23 '21 20:04 CrepeGoat

Could you try to install libsamplerate through Homebrew?

$ brew install libsamplerate

The binary shipped with python-samplerate unfortunately still contains instructions for a newer processor generation.

tuxu avatar Apr 25 '21 11:04 tuxu

The binary shipped with python-samplerate unfortunately still contains instructions for a newer processor generation.

so is my problem that my processor is too old for the OSX wheel for this package? Is such a compatible wheel something I could make and contribute to this package?

Could you try to install libsamplerate through Homebrew?

...ok it took me a couple reads to understand this right, sorry... here you're asking me to install the required DLL, NOT the package itself.

In that case, it seems like it'd be more useful to fix the wheels/tarball than do a one-time fix on just my machine. But that depends on your response to my first comment, I guess. I'm curious what you think!

CrepeGoat avatar Apr 29 '21 17:04 CrepeGoat

Yes, indeed. I took the binary from a Homebrew installation on my 2014 MacBook Pro (3 GHz, Core i7). Unfortunately the binary was optimized for this CPU when I installed it.

Regarding the second point: I fully agree that the wheel should be fixed! However, the dylib that is included in the wheel will only be used if libsamplerate can't be found elsewhere on your system. So installing the library through Homebrew should resolve the problem too, without modifying the wheel or Python installation.

tuxu avatar Apr 30 '21 17:04 tuxu