Skip to content
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

Broken with libFLAC < 1.4.0 ("internal psf_fseek() failed") #486

Open
bemoody opened this issue May 14, 2024 · 4 comments
Open

Broken with libFLAC < 1.4.0 ("internal psf_fseek() failed") #486

bemoody opened this issue May 14, 2024 · 4 comments

Comments

@bemoody
Copy link
Collaborator

bemoody commented May 14, 2024

Some versions of the SoundFile package on PyPI, including the latest version (0.12.1), appear to be broken. It appears that something is wrong with the precompiled "libsndfile_x86_64.so". I have no idea about other platforms. I don't know if this is actually a bug in libFLAC, or in libsndfile, or in SoundFile, or a bug in how libFLAC/libsndfile was compiled.

The latest version in the libsndfile-binaries repo is possibly fixed, but there hasn't been a new release of SoundFile for a while.

Here is an example file, gzipped and base64ed:

H4sIAAAAAAACA0vzSXRmYGBQEmAQAFKCDGzi4gUsHxiY/BiUfKRUi1hP7hBiWKmeMlUwt4WBQUMB
qKYoNS21KDUvOVUhJzPJzcfRWcFQz1jPWMHIwNDSwMLABKiE4f+P0xoMb4UZmFns/6OC+f9HFnj4
f2SDf2oMbBz1aIL2IywQDo/wRPDHh4FHAD1h1I+wQGgf4YngR/0yULXA+IoBBnhVQQJMj+ECQdEg
AeYncIHnRSABlo9wgTfLQQKs3+ACkX0gAbb/cAG2DyAB9h9wgc03QQIcV+ECglEgAc5LcIElxSAB
rttwgd+8IAHuO3ABPxWQAM9JuIDrR5AA7zm4wIcbIAG+43CB9WDf8h+AC0j1gwQE5sIFspaCBARn
wQXu94AEhCbDBRo+gQSEp8AFTG+DBEQa4QJ2fCAB0Ta4QLc6SECsHy5wJRIkIN4BF0gsAAlILIUL
HP4MEpBcBBcouwUSkFoNF9BcAhKQXgMXmNMLEpDZCReYHgESkN0HF1AqBAnIbYcL1PKDBOQ3wAVO
qIEEFHjhAnPBsa/IBRfQAMe+EjNcoJwHJKDMAhc4BExB1RoqvP9nMjMwMYwCfIBxsLcU2BhYRmMJ
L2Ae7PU8DwPHaCzhBeyDvZY+wAsARLgU7hMOAAA=

I think this is a valid FLAC file, though I'm not sure. Running python3 -c 'import soundfile; soundfile.SoundFile("example.dat").read(78419)' should succeed.

  • With python3-soundfile (and libsndfile) from Debian bookworm, it works.
  • With libsndfile_x86_64.so from commit f5311e9 (md5 = 8e42bd39f38254cf9a5c8ad1bc975faa), it fails.
  • With libsndfile_x86_64.so from commit 1ddbbd5 (md5 = 44c0cbf5b8f2a96d309d3e648718bdec), it fails.
  • With libsndfile_x86_64.so from commit f1655ba (md5 = 1bd1cc5a1b3724c97ea26d007110e5f1), it works.
  • With libsndfile_x86_64.so from commit 42c638d (md5 = 243f680f7a517539fe867731fc5fd5d0), it works.
@tompollard
Copy link
Member

tompollard commented Jul 10, 2024

Okay, sorry, got it. I'm now first doing this:

base64 -d -i example.txt -o example.zip
gzip -dc example.zip > example.dat

On MacOS 14.6 Beta (23G5061b) M1 Max, I see the error for soundfile==0.11.0 but not for 0.12.1

soundfile==0.11.0

pip install soundfile==0.11.0
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/tompollard/projects/wfdb-python/env/lib/python3.9/site-packages/soundfile.py", line 892, in read
    frames = self._array_io('read', out, frames)
  File "/Users/tompollard/projects/wfdb-python/env/lib/python3.9/site-packages/soundfile.py", line 1341, in _array_io
    return self._cdata_io(action, cdata, ctype, frames)
  File "/Users/tompollard/projects/wfdb-python/env/lib/python3.9/site-packages/soundfile.py", line 1353, in _cdata_io
    self.seek(curr + frames, SEEK_SET)  # Update read & write position
  File "/Users/tompollard/projects/wfdb-python/env/lib/python3.9/site-packages/soundfile.py", line 799, in seek
    _error_check(self._errorcode)
  File "/Users/tompollard/projects/wfdb-python/env/lib/python3.9/site-packages/soundfile.py", line 1404, in _error_check
    raise LibsndfileError(err, prefix=prefix)
soundfile.LibsndfileError: Internal psf_fseek() failed.

soundfile==0.12.1

pip install soundfile==0.12.1

Runs without error.

@bemoody
Copy link
Collaborator Author

bemoody commented Jul 10, 2024

Thanks. That's what I expected. The soundfile builds using libFLAC 1.3.3 apppear to be affected by #486 but not #488; the soundfile builds using libFLAC 1.4.2 appear to be affected by #488 but not #486.

@bemoody
Copy link
Collaborator Author

bemoody commented Jul 12, 2024

After hammering on this a bit more, it looks like this is actually a bug in libFLAC, and not a bug in libsndfile.

For example, running flac -df -o /dev/null bug486.dat --skip=78420 fails.

However, this bug is not detected by the prober I posted in #488. And as we've seen, this bug exists in libFLAC 1.3.3 but not 1.4.2, whereas the other bug exists in 1.4.2 but not 1.3.3.

@bemoody
Copy link
Collaborator Author

bemoody commented Jul 12, 2024

1.2.0 broken
...
1.3.3 broken
1.3.4 broken

fixed by 3fc5ba46375e48009cd9428091cd2ffd242de6b9

1.4.0 working
1.4.1 working
1.4.2 working
1.4.3 working

@bemoody bemoody changed the title Broken with some versions of SoundFile ("internal psf_fseek() failed") Broken with libFLAC < 1.4.0 ("internal psf_fseek() failed") Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants