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

Segmentation fault in fluidsynth.py and other problems on Ubuntu 22.04.1 LTS #63

Open
bomm opened this issue Jan 3, 2023 · 10 comments
Open

Comments

@bomm
Copy link

bomm commented Jan 3, 2023

I think the problem occurs since upgrading to Ubuntu 22.04.1 LTS from Ubuntu 20.04.5 LTS (I'm not sure if the last number was 5.)

Is there anyone using EasyABC on Ubuntu 22.04.1 LTS?
Or is there anyone using EasyABC with libfluidsynth.so.3 on any Linux?

When I start easy_abc.py, it is terminated with Segmentation fault.

Using pdb I traced it down to this Python call stack:
F.fluid_settings_setnum(self.settings, c_char_p(b(name)), c_double(value)) in fluidsynth.py:85
self.setting_setnum('synth.gain', gain) in fluidsynth.py:62
self.fs = F.Synth(gain=1.0, bsize=2048) # make a synth in fluidsynthplayer.py:17
self.mc = FluidSynthPlayer(init_soundfont_path) in easy_abc.py:3976

On my system it uses libfluidsynth.so.3 which is

lrwxrwxrwx 1 root root     22 Feb  3  2022 /usr/lib/x86_64-linux-gnu/libfluidsynth.so.3 -> libfluidsynth.so.3.0.5
-rw-r--r-- 1 root root 551240 Feb  3  2022 /usr/lib/x86_64-linux-gnu/libfluidsynth.so.3.0.5

I don't know if this is a problem of libfluidsynth or the Python wrappers.
In Ubuntu 20.04.5 LTS, libfluidsynth.so.3 was not yet available, only libfluidsynth.so.2, which is a link to libfluidsynth.so.2.3.1.

There are incompatible changes between libfluidsynth.so.3 and libfluidsynth.so.2. I don't know if they affect thy Python interface.
See https://www.fluidsynth.org/api/RecentChanges.html#NewIn2_2_0

Additional research:
After installing libfluidsynth2_2.1.1-2_amd64.deb from the Ubuntu FocalFossa repository and changing the order of the library versions in fluidsynth.py to prefer libfluidsynth.so.2 does not change the behavior. With libfluidsynth.so.2 I get a segmentation fault at the same Python code line.

The fluidsynth command line program which uses libfluidsynth.so.3 is able to play a MIDI file without crash.

@bomm
Copy link
Author

bomm commented Jan 3, 2023

I tried to replace fluidsynth.py with the version from https://github.com/nwhitehead/pyfluidsynth. I had to copy and modify class Player and add a few API functions that were not defined in Nathan Whitehead's version. see attached file
fluidsynth.py.txt
updated version in my next comment: #63 (comment)

Now the crash is gone, but I have lots of invisible GUI elements and error messages like

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/wx/lib/agw/aui/auibar.py", line 3501, in OnPaint
    self._art.DrawSeparator(dc, self, item_rect)
  File "/usr/lib/python3/dist-packages/wx/lib/agw/aui/auibar.py", line 1269, in DrawSeparator
    rect.x += (rect.width/2)
TypeError: 'float' object cannot be interpreted as an integer

This seems to be an issue with wxWidgets and Python 3.10: wxWidgets/Phoenix#2038

@bomm bomm changed the title Segmentation fault in fluidsynth.py on Ubuntu 22.04.1 LTS Segmentation fault in fluidsynth.py and other problems on Ubuntu 22.04.1 LTS Jan 3, 2023
@bomm
Copy link
Author

bomm commented Jan 3, 2023

By installing python3-wxgtk4.0_4.2.0+dfsg-1_amd64.deb and its dependencies libwxgtk3.2-0_3.2.1+dfsg-1_amd64.deb, libwxbase3.2-0_3.2.1+dfsg-1_amd64.deb, python3-wxgtk-media4.0_4.2.0+dfsg-1_amd64.deb and libwxgtk-media3.2-0_3.2.1+dfsg-1_amd64.deb from the upcoming Ubuntu 23.04 Lunar Lobster I could fix the wxWidgets incompatibility with Python 3.10.

After this I noticed some missing libfluidsync API functions which were not defined in my modified version of fluidsync.py. See new attachment fluidsynth.py.txt

Now I still get an error I could not track down: fluidsynth: error: Unknown integer parameter 'bsize'

And some GTK assertion messages with a nonexistent line number: (easy_abc.py:148716): Gtk-CRITICAL **: 21:29:04.409: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar

EasyABC is now working again.

Edit:
When opening the ABC settings, I get several error messages:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/wx/lib/rcsizer.py", line 153, in CalcMin
    size = wx.Size( reduce( operator.add, self.colWidths),
TypeError: Size(): arguments did not match any overloaded call:
  overload 1: too many arguments
  overload 2: argument 1 has unexpected type 'float'
  overload 3: argument 1 has unexpected type 'float'

and

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/wx/lib/rcsizer.py", line 163, in RecalcSizes
    minWidth, minHeight  = self.CalcMin()
  File "/usr/lib/python3/dist-packages/wx/lib/rcsizer.py", line 153, in CalcMin
    size = wx.Size( reduce( operator.add, self.colWidths),

and in 4 of the 6 tabs, the GUI elements are all in the top left corner.

Might be another problem of wxWidgets with Python 3.10.

I was able to fix this by modifying the file /usr/lib/python3/dist-packages/wx/lib/rcsizer.py, see wxWidgets/Phoenix#2038 (comment)

@Redmattski
Copy link

I have been using EasyABC on Arch Linux against libfluidsynth.so.3. Some of the changes that I needed to apply were:

Hope this helps

@revad
Copy link

revad commented Jan 10, 2023

I got v1.3.8.6 (from SF) to work on OpenSUSE 15.4 with:
python 3.6 (which is still the system version)
SUSE pkgs: fluidsynth 2.2.2, libfluidsynth3 2.2.2, fluid-soundfont-gm 3.1, gstreamer-plugins-bad-fluidsynth 1.20.1
pkg python3-fluidity-SM is not installed; installing it generates errors and stops easy-ABC playing repeats correctly.

wxpython is 4.1.1

I used @bomm 's amended fluidsynth.py.txt from #issuecomment-1370203164 above.
That got rid of the segfault; I did not need the fix to fluidsynth.py from issue #28

It generates these messages on starting

fluidsynth: error: Unknown integer parameter 'bsize'
fluidsynth: Using PulseAudio driver
fluidsynth: warning: Failed to set thread to high priority

It always plays from the beginning, as it did with v1.3.7.7 under python 2.

@robertmuth
Copy link

This hacked up version in a fork works for me on Ubuntu 22.04.2 LTS

https://github.com/robertmuth/EasyABC/tree/ubuntu.22.04

@topchyan
Copy link

bump

@wxtim
Copy link

wxtim commented Mar 25, 2023

This hacked up version in a fork works for me on Ubuntu 22.04.2 LTS

https://github.com/robertmuth/EasyABC/tree/ubuntu.22.04

I've just tried this and it works. I'm not associated with @jwdj, but I'd be happy to review any PR to this repo. I can confirm that your branch works for me locally on Ubuntu 22.04. 😄

Now I've got some smallpipe variations to write...

@mausch
Copy link

mausch commented Jun 23, 2023

Give this a try: #72

@revad
Copy link

revad commented Oct 5, 2023

I thought I had fluidsynth working with SUSE Linux - most recently on SuSE Leap 15.5 - see #76
But when I tried some different soundfonts I discovered that it was actually using timidity. So I did some tracing.

I had included the code here which had got rid of the segfault:
#28 (comment)

But I found that it never returns from this statement:
F.fluid_audio_driver_register(arr)
I noted that c_char_p parameters should be utf-8 bytes so I changed this:

#L = ["jack", "pulseaudio", None]
L = [b"jack", b"pulseaudio", None]

The fluid_audio_driver_register() now returns 0. But it segfaults when it hits
self.setting_setnum('synth.gain', gain)

I got rid of latin-1 in the encode() so it's utf-8 but that makes no difference.

Has anybody got a recent version of EasyABC to work with Linux and fluidsynth and checked that it's actually using fluidsynth? I had assumed it was because it didn't give the warning that it wasn't, and I'd specified a soundfont in the settings. I had to put a different soundfont into timidity to discover what was being used.

@markblinkhorn
Copy link

@bomm
I have made some modifications to fluidsynth.py, mainly to correct a problem affecting it running on 64-bit Windows, but it might just help with the segfaults that you have mentioned. The modified version is in the repo at https://github.com/jwdj/EasyABC/blob/master/fluidsynth.py

Also, I'd be grateful for your feedback as I have only been able to test the mods on 64bit Windows and Linux bookworm - it would be nice to know whether it also works on other Linux distros

Mark

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

8 participants