Hydrogen: H2 segfaults when switching to next song while receiving MIDI

Created on 26 Sep 2018  路  9Comments  路  Source: hydrogen-music/hydrogen

Hydrogen version * : be8ecd073b167e569d7a61b881d3a9505014f5eb
Operating system + version : ubuntu 16.04
Audio driver + version : jack


when you use a playlist you can hit F5/F6 to jump to the next /previous song in the playlist
if you hit F5/F6 while you are sending MIDI to H2 (via a controller interface of soft midi controller) H2 segfaults
this is 100% reproducible

MIDI related bug

All 9 comments

Hm.. it segfaults here also without any midi activity while switching songs :smile:

I've fixed one rather obvious bug when removing a song, but i'm not sure if this was also your problem which is described in this issue. Could you re-test this problem with the current master?

just retested with the latest code : problem remains
will gather some more data and post it here

running h2 in gdb gives me this when h2 segfaults :

Thread 12 "hydrogen" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffc4e1e700 (LWP 12518)]
0x0000000000505f4a in H2Core::Song::get_instrument_list (this=0x0) at /home/tvanseve/Code/prive/hydrogenMay2018/src/core/include/hydrogen/basics/song.h:130
130 return __instrument_list;

could it be that when you hit F5/F6 H2 cleans up all instruments of the current song before it loads the new song, and when it receives midi in for a non-existing instrument during this transition it crashes ?

Changing song involves unloading old drumkit and replacing it with one freshly loaded from new song. Maybe Hydrogen receives MIDI message while no drumkit is loaded?

Best regards,
Przemek

Ok i'm in trouble :-(
My BCR controller is acting up and 2 knobs just jitter more and more : they randomly jump up/down 1 without me touching the knobs and thus send midi to H2 at random times.
This is what made me log this issue, but it has gotten wors, a lot worse) ... as a consequence it is now nearly impossible to switch between songs using F5/F6.
To make matters worse i have a gig this weekend and i have no time to get a new BCR + config it properly (i have a highly customized config on the BCR) ...
Would there be an easy fix for this issue ?

I am trying to see if i can temporarily disconnect the BCR from H2 during a switch to the next song, but it's not that simple to do so all help is highly appreciated !

Hi!

There is a chance that this issue does not happen with 1.0-beta1, so you could try to use that version. Maybe i can have a look at the issue tomorrow, but i can't promise a quick fix.

Hi,

I looked into this issue - I hope my fix solves this issue.

However, I discovered potential larger issue. It seems that MIDI drivers are active objects i.e. they process incoming MIDI message in their own thread, either directly, by calling pthread create (ALSA driver) or indirectly, by underlying libraries (CoreMIDI and JACK). That means that MIDI messages are handled in separate thread which means that Hydrogen state is being manipulated by two threads (main thread and MIDI handler thread) - that might lead to synchronization issues.

I imagine that solution would be that MIDI drivers push incoming MIDI messages into EventQueue and main thread would pop them from there and handle them. I'm unsure if that's possible, how much effort would be required and what would be performance impact though.

Hi!

The fix of @elpescado is now in the master branch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elpescado picture elpescado  路  8Comments

theGreatWhiteShark picture theGreatWhiteShark  路  7Comments

oddtime picture oddtime  路  6Comments

elpescado picture elpescado  路  7Comments

Porrumentzio picture Porrumentzio  路  13Comments