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

Segfault when attempting to load RIFF SF2 soundbank #652

Closed
v1993 opened this issue Jun 7, 2020 · 3 comments
Closed

Segfault when attempting to load RIFF SF2 soundbank #652

v1993 opened this issue Jun 7, 2020 · 3 comments

Comments

@v1993
Copy link

v1993 commented Jun 7, 2020

FluidSynth version

2.1.1

Describe the bug

When I try to load specific SoundFont (Stgiga's HiDef Soundfont (2019-05-25).sf2, RIFF (little-endian) data SoundFont/Bank) fluidsynth crashes with error message and segfault:

v@v-home:~$ fluidsynth Downloads/Stgiga\'s\ HiDef\ Soundfont\ \(2019-05-25\).sf2
FluidSynth runtime version 2.1.1
Copyright (C) 2000-2020 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.

fluidsynth: error: File read failed
fluidsynth: error: Failed to read sample data
fluidsynth: error: Attempted to read 1411452394 words of sample data, but got -1 instead
fluidsynth: error: Unable to load all sample data

** (process:32741): CRITICAL **: 13:34:22.287: ipatch_container_init_iter: assertion 'IPATCH_IS_CONTAINER(container)' failed
Segmentation fault (core dumped)

Expected behavior

Fluidsynth loads soundfont without any problems (or at least handles error gracefully and avoids segfault).

Steps to reproduce

  1. Get soundbank from link
  2. Attempt to load it using fluidsynth

Additional context

It seems to me some sort of regression as some time before (can't post exact version sadly) qsynth had no problems loading this exact soundfont. I'm usually using qsynth and have resorted to command line fluidsynth only after meeting with this issue. Due to segfault caused by this issue qsynth now crashes on startup.

@v1993 v1993 added the bug label Jun 7, 2020
@mawe42
Copy link
Member

mawe42 commented Jun 7, 2020

I can confirm this behaviour with v2.1.1, v2.1.2 and v2.1.3 on Linux.

Current master does not show the problem and a quick bisect reveals that it has already been fixed by 9995fd8 (the fix for #629). Which is interesting, as #629 was about a Windows-only problem.

@derselbst
Copy link
Member

derselbst commented Jun 7, 2020

Fluidsynth fails to load this soundfont, because we used to pass an integer to fread().

https://github.com/FluidSynth/fluidsynth/pull/629/files#diff-033efa405126e8aa738c6a502777cd61R48

It then attempts to read a negative number of bytes. Because of that I doubt that "qsynth had no problems loading this exact soundfont" before. On recent master, this int has been promoted to long long in #629. I didn't realize that this fixed loading on linux as well. Yet, I'll propose a minor follow-up fix to this issue in a second.

After fluidsynth failed to load the SF2, it passes loading to libinstpatch, which also fails. The following crash is a duplicate of swami/libinstpatch#48. Compile against libinstpatch 1.1.5 to fix the crash.

@v1993
Copy link
Author

v1993 commented Jun 7, 2020

I'm sure that I was using this soundfont with qsynth and problem showed up only after update a while ago. It's great that both issue and segfault already got fixed in respective masters!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants