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 #28

Open
PigeonOnTheGate opened this issue Oct 18, 2020 · 23 comments
Open

Segmentation fault #28

PigeonOnTheGate opened this issue Oct 18, 2020 · 23 comments

Comments

@PigeonOnTheGate
Copy link

Thank you for fixing the my last issue. However, after I finally got around to updating easyabc to the latest version, the program no longer starts. It instead gives an error:

fluidsynth: warning: SDL2 not initialized, SDL2 audio driver won't be usable /usr/bin/easyabc: line 2: 9134 Segmentation fault (core dumped) python3 /usr/share/easyabc/easy_abc.py

Thank you very much for your help

@jwdj
Copy link
Owner

jwdj commented Oct 21, 2020 via email

@PigeonOnTheGate
Copy link
Author

Thanks so much for the advice! I do have all of the above installed. Since this is a warning rather than an error, is there a way to make the program run in spite of it? I've noticed easyABC does start if I remove fluidsynth entirely, so if I'm unable to solve this, I'll just remove fluidsynth and use an external midi player.

After googling, I found someone who had a similar problem due to a missing line of code. Do you think the solution from there might work?

@jwdj
Copy link
Owner

jwdj commented Oct 24, 2020 via email

@PigeonOnTheGate
Copy link
Author

PigeonOnTheGate commented Oct 25, 2020

I'm using FluidSynth 2.1.5, which I installed from a package. I have also tried setting FluidSynth's driver to JACK and ALSA, but strangely enough, the same warning and segmentation fault occur. I checked dependencies, and a number of packages depend on SDL2, including fluidsynth, python3-wxpython, and easyabc itself. Here are my fluidsynth settings, maybe I need to change something here for things to work?

audio.alsa.device default
audio.driver jack
audio.file.endian auto
audio.file.format s16
audio.file.name fluidsynth.wav
audio.file.type auto
audio.jack.autoconnect False
audio.jack.id fluidsynth
audio.jack.multi False
audio.jack.server
audio.oss.device /dev/dsp
audio.period-size 64
audio.periods 16
audio.pulseaudio.adjust-latency True
audio.pulseaudio.device default
audio.pulseaudio.media-role music
audio.pulseaudio.server default
audio.realtime-prio 60
audio.sample-format 16bits
audio.sdl2.device default
midi.alsa.device default
midi.alsa_seq.device default
midi.alsa_seq.id pid
midi.autoconnect False
midi.driver alsa_seq
midi.jack.id fluidsynth-midi
midi.jack.server
midi.oss.device /dev/midi
midi.portname
midi.realtime-prio 50
player.reset-synth True
player.timing-source sample
shell.port 9800
shell.prompt >
synth.audio-channels 1
synth.audio-groups 1
synth.chorus.active True
synth.chorus.depth 8.000
synth.chorus.level 2.000
synth.chorus.nr 3
synth.chorus.speed 0.300
synth.cpu-cores 1
synth.default-soundfont /usr/share/soundfonts/default.sf2
synth.device-id 0
synth.dynamic-sample-loading False
synth.effects-channels 2
synth.effects-groups 1
synth.gain 0.200
synth.ladspa.active False
synth.lock-memory True
synth.midi-bank-select gs
synth.midi-channels 16
synth.min-note-length 10
synth.overflow.age 1000.000
synth.overflow.important 5000.000
synth.overflow.important-channels
synth.overflow.percussion 4000.000
synth.overflow.released -2000.000
synth.overflow.sustained -1000.000
synth.overflow.volume 500.000
synth.polyphony 256
synth.reverb.active True
synth.reverb.damp 0.000
synth.reverb.level 0.900
synth.reverb.room-size 0.200
synth.reverb.width 0.500
synth.sample-rate 44100.000
synth.threadsafe-api True
synth.verbose False

@PigeonOnTheGate
Copy link
Author

I have just noticed that if I run fluidsynth in the terminal, a number of errors are shown, if I run it from the root, however, these errors do not occur. Could these be the cause of the segmentation fault?

When I run fluidsynth from the terminal, it shows:

FluidSynth runtime version 2.1.5
Copyright (C) 2000-2020 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
fluidsynth: warning: Failed to set thread to high priority
jackdmp 1.9.14
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2019 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
Cannot create RT messagebuffer thread: Operation not permitted (1)
Retrying messagebuffer thread without RT scheduling
Messagebuffer not realtime; consider enabling RT scheduling for user
no message buffer overruns
Cannot create RT messagebuffer thread: Operation not permitted (1)
Retrying messagebuffer thread without RT scheduling
Messagebuffer not realtime; consider enabling RT scheduling for user
no message buffer overruns
Cannot create RT messagebuffer thread: Operation not permitted (1)
Retrying messagebuffer thread without RT scheduling
Messagebuffer not realtime; consider enabling RT scheduling for user
no message buffer overruns
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Cannot lock down 86611866 byte memory area (Cannot allocate memory)
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
Cannot use real-time scheduling (RR/10) (1: Operation not permitted)
AcquireSelfRealTime error
Cannot lock down 86611866 byte memory area (Cannot allocate memory)
fluidsynth: Jack sample rate mismatch, adjusting. (synth.sample-rate=44100, jackd=48000)
Cannot use real-time scheduling (RR/5) (1: Operation not permitted)
JackClient::AcquireSelfRealTime error

When I run it from the terminal as root, it shows:

Warning: Unable to initialize SDL2 Audio: Could not setup connection to PulseAudiofluidsynth: warning: SDL2 not initialized, SDL2 audio driver won't be usable
FluidSynth runtime version 2.1.5
Copyright (C) 2000-2020 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jackdmp 1.9.14
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2019 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
no message buffer overruns
no message buffer overruns
no message buffer overruns
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
fluidsynth: Jack sample rate mismatch, adjusting. (synth.sample-rate=44100, jackd=48000)

@PigeonOnTheGate
Copy link
Author

The errors that fluidsynth was giving me were related to JACK, and I was able to fix them with this method , unfortunately, this did nothing to fix the segmentation fault with easyABC, so this is another dead end. In any case, running fluidsynth now gives this output

FluidSynth runtime version 2.1.5
Copyright (C) 2000-2020 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jackdmp 1.9.14
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2019 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
no message buffer overruns
no message buffer overruns
no message buffer overruns
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
fluidsynth: Jack sample rate mismatch, adjusting. (synth.sample-rate=44100, jackd=48000)
Type 'help' for help topics.

@jwdj
Copy link
Owner

jwdj commented Oct 29, 2020 via email

@PigeonOnTheGate
Copy link
Author

Thank you. Running this gave some interesting output:

fluidsynth: warning: SDL2 not initialized, SDL2 audio driver won't be usable
Fatal Python error: Segmentation fault

Current thread 0x00007fadab4d2740 (most recent call first):
  File "/usr/share/easyabc/fluidsynth.py", line 65 in setting_setnum
  File "/usr/share/easyabc/fluidsynth.py", line 51 in __init__
  File "/usr/share/easyabc/fluidsynthplayer.py", line 15 in __init__
  File "/usr/share/easyabc/easy_abc.py", line 3698 in __init__
  File "/usr/share/easyabc/easy_abc.py", line 8336 in NewMainFrame
  File "/usr/share/easyabc/easy_abc.py", line 8377 in OnInit
  File "/usr/lib64/python3.8/site-packages/wx/core.py", line 2194 in __init__
  File "/usr/share/easyabc/easy_abc.py", line 8314 in __init__
  File "/usr/share/easyabc/easy_abc.py", line 8385 in <module>
/usr/bin/easyabc: line 2: 28220 Segmentation fault      (core dumped) python3 /usr/share/easyabc/easy_abc.py

@jwdj
Copy link
Owner

jwdj commented Nov 2, 2020 via email

@PigeonOnTheGate
Copy link
Author

Hi, I fiddled around with the code a bit, and tried commenting out the non-essential lines that would cause errors. Eventually I ended up with this:

class Synth: # interface for the FluidSynth synthesizer
def init(self, gain=0.2, samplerate=44100.0, bsize=64):
self.settings = F.new_fluid_settings()
# self.setting_setnum('synth.gain', gain)
# self.setting_setnum('synth.sample-rate', samplerate)
# self.setting_setint('audio.period-size', bsize)
# self.setting_setint('audio.periods', 2)
self.synth = F.new_fluid_synth(self.settings)
self.audio_driver = None

at this point, only essential lines were left, but these were still causing errors:

fluidsynth: warning: SDL2 not initialized, SDL2 audio driver won't be usable
Fatal Python error: Segmentation fault

Current thread 0x00007f6616c44740 (most recent call first):
File "/usr/share/easyabc/fluidsynth.py", line 55 in init
File "/usr/share/easyabc/fluidsynthplayer.py", line 15 in init
File "/usr/share/easyabc/easy_abc.py", line 3698 in init
File "/usr/share/easyabc/easy_abc.py", line 8336 in NewMainFrame
File "/usr/share/easyabc/easy_abc.py", line 8377 in OnInit
File "/usr/lib64/python3.8/site-packages/wx/core.py", line 2194 in init
File "/usr/share/easyabc/easy_abc.py", line 8314 in init
File "/usr/share/easyabc/easy_abc.py", line 8385 in
/usr/bin/easyabc: line 2: 12047 Segmentation fault (core dumped) python3 /usr/share/easyabc/easy_abc.py

What seems so strange to me here is that the code is able to import the library (there is no import error), but attempting to inintialize fluidsynth causes the program to crash. I haven't been able to find anyone else having similar issues with fluidsynth, and I can't really tell if this is an issue with fluidsynth, the easyabc code, or if something is wrong in my settings.

@PigeonOnTheGate
Copy link
Author

PigeonOnTheGate commented Nov 12, 2020

I think I may have found something in the fluidsynth api http://www.fluidsynth.org/api/audio_8h.html

When creating a settings instance with new_fluid_settings(), all audio drivers are initialized once. In the past this has caused segfaults and application crashes due to buggy soundcard drivers.

This could explain why the program would cause a segfault on my computer and not on yours, as we might have different audio drivers installed.

@PigeonOnTheGate
Copy link
Author

from what I can gather here and here, it seems that when fluidsynth is initialized with new_fluid_settings(), it initializes all audio drivers. One of these audio drivers may segfault, causing fluidsynth to crash. It seems that the solution to this is to identify which driver is the culprit and exclude it by using the fluid_audio_driver_register() command.

@jwdj
Copy link
Owner

jwdj commented Sep 15, 2021

On Linux EasyABC now uses pulseaudio as audio driver for FluidSynth. Does that solve this issue perhaps?

@PigeonOnTheGate
Copy link
Author

Thanks so much - trying it out right now.
Should I leave the "midi player" field blank or put fluidsynth?

@jwdj
Copy link
Owner

jwdj commented Sep 16, 2021

To be able to use FluidSynth as audio player you should indeed leave the midi player field blank and select a sound font.
Some good SoundFonts are freely available.

@PigeonOnTheGate
Copy link
Author

When I leave the midi player field blank and select a soundfont, I still get a gstreamer error and no playback. If I press play, I get two pop-ups: one says "media playback error: Internal data stream error." and the other says "Unable to load /home/username/.EasyABC/cache/temp.midi: unsupported format?" I tried the workaround with jackd from here, but it gives the same exact result. Oddly enough, if I select fluidsynth as an external player, it works. Is there a way to get more info on those errors and why the program isn't working?

Thanks so much

@jwdj
Copy link
Owner

jwdj commented Sep 17, 2021

Since your FluidSynth is working as an external player you probably have done: sudo apt install libfluidsynth2 fluid-soundfont-gm
The SoundFont is not used straight away. It requires a restart.
If the fluidsynth library is found and the soundfont exists at startup then it should work. (it shows a warning if FluidSynth can't be loaded/found)

@PigeonOnTheGate
Copy link
Author

Could be a library issue. My fluidsynth library is now called libfluidsynth3 after an update a few months ago. I'll try to see if I can downgrade it to libfluidsynth2.

@robertmuth
Copy link

I am see a similar issue after upgrading from ubuntu 21.10 to 22.04 both using pipewire.

The segfault looks like

python3 ./easy_abc.py

Fatal Python error: Segmentation fault

Current thread 0x00007f962ae9f000 (most recent call first):
  File "/home/rm/EasyABC/fluidsynth.py", line 85 in setting_setnum
  File "/home/rm/EasyABC/fluidsynth.py", line 62 in __init__
  File "/home/rm/EasyABC/fluidsynthplayer.py", line 17 in __init__
  File "/home/rm/EasyABC/./easy_abc.py", line 3974 in __init__
  File "/home/rm/EasyABC/./easy_abc.py", line 8710 in NewMainFrame
  File "/home/rm/EasyABC/./easy_abc.py", line 8771 in OnInit
  File "/usr/lib/python3/dist-packages/wx/core.py", line 2137 in __init__
  File "/home/rm/EasyABC/./easy_abc.py", line 8688 in __init__
  File "/home/rm/EasyABC/./easy_abc.py", line 8787 in <module>

Extension modules: wx._core, wx._html, wx._stc (total: 3)
Segmentation fault (core dumped)

When I try to run fluidsynth standalone I get:

fluidsynth

FluidSynth runtime version 2.2.5
Copyright (C) 2000-2022 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.

ALSA lib pcm_dmix.c:1032:(snd_pcm_dmix_open) unable to open slave
fluidsynth: error: Failed to open the "default" audio device
Failed to create the audio driver. Giving up.
fluidsynth: warning: Failed to set thread to high priority

This gets slightly better via:

fluidsynth -a pulseaudio OR fluidsynth -a jack

FluidSynth runtime version 2.2.5
Copyright (C) 2000-2022 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.

fluidsynth: warning: Failed to set thread to high priority
fluidsynth: Using PulseAudio driver
Type 'help' for help topics.

@robertmuth
Copy link

Looking into this some more it seems that under ubuntu 22.04 python3.10 and libfluidsynth3:amd64 any access to the settings object created by:
self.settings = F.new_fluid_settings()

fails

@robertmuth
Copy link

inserting the stamza below got rid of the seg-fault

        # start of new code
        L = ["jack", "pulseaudio", None]
        arr = (c_char_p * len(L))()
        arr[:] = L
        F.fluid_audio_driver_register(arr)
        # end of new code
        self.settings = F.new_fluid_settings()

However, there is a new problem with Gstreamer that results in annoying alert-boxes:

12:22:05 PM: Media playback error: Resource not found.
12:22:05 PM: Media playback error: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.

@robertmuth
Copy link

My last problem could be solved by commenting out the lines like:

mc.Load('NONEXISTANT_FILE____.mid')

based on:

https://sourceforge.net/p/easyabc/discussion/general/thread/524f3f9c/?limit=25

@Redmattski
Copy link

inserting the stamza below got rid of the seg-fault

        # start of new code
        L = ["jack", "pulseaudio", None]
        arr = (c_char_p * len(L))()
        arr[:] = L
        F.fluid_audio_driver_register(arr)
        # end of new code
        self.settings = F.new_fluid_settings()

I can confirm this solution is working on Arch Linux and resolves the Seg Fault.

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

4 participants