View Issue Details

IDProjectCategoryView StatusLast Update
0006287ardourbugspublic2020-04-19 20:17
Reporterx42 Assigned Todrobilla  
Status closedResolutionfixed 
Product Version4.X git (version in description) 
Summary0006287: session save during playback can produce invalid midi data
Descriptionplay some midi-track, press save (or wait for periodic-save to kick in) -> stuck or lost midi events.

this is caused by the iterator in MidiSource::midi_read().

MidiSource::session_saved() either directly or indirectly via SMFSource::flush_midi() resets the model and the iterator. If here if there's existing data in the _playback_buf and continue reading various side effects can manifest.

I still don't see an easy fix for this.

related bug:
libs/evoral/src/Sequence.cpp:103 only adds active notes if they're active at time t.
but time t is with read-ahead.
TagsNo tags attached.



2015-05-02 03:12

administrator   ~0016671

Last edited: 2015-05-02 05:01

some notes on tracking this down. in MidiSource::midi_read
even if the model/iterator is *not* invalidated, one should expect that looking up the iterator should yield the same position as the current iterator.
Test sequence:
1) T=00 Note-on 1
2) T=10 Note-off 1
3) T=10 Note-on 2
4) T=20 Note-off 2
5) T=20 Note-on 3
6) T=30 Note-off 3
Current iterator is at (4). That is the next event to be read.
But _model->begin(conveter( 20 ) ,..) returns iterator (5)
Sequence...::operator++() does not see event (4) and hence does not call _active_notes.pop();
-> stuck note
The reason why 5 is returned is _note_iter = seq.note_lower_bound(t);
std::multiset::lower_bound() is correct but seq.notes() only contains note-on events.

since the iterator after a _model->begin(...) is always at a note-on ... the _active_notes.pop(); is not called)

proposed fix:
 * change Lock to RWLock (and don't invalidate model on save in the first place)
 * also make begin correctly position itself at note off, if given (for live edits)


2015-05-13 00:13

developer   ~0016684

Fixed in 4.0-312-g4d2d693

Simple fix since we already had all the required mechanism for the live edit stuff. I am not quite sure about this in all cases, *too many* notes might stick around, but am unable to reproduce the issue any longer after this change.


2020-04-19 20:17

developer   ~0023450

Issue has been closed automatically, by Trigger Close Plugin.
Feel free to re-open with additional information if you think the issue is not resolved.

Issue History

Date Modified Username Field Change
2015-04-28 15:00 x42 New Issue
2015-05-02 03:12 x42 Note Added: 0016671
2015-05-02 05:01 x42 Note Edited: 0016671
2015-05-13 00:13 drobilla Note Added: 0016684
2015-05-13 00:13 drobilla Assigned To => drobilla
2015-05-13 00:13 drobilla Status new => resolved
2015-05-13 00:13 drobilla Resolution open => fixed
2020-04-19 20:17 system Note Added: 0023450
2020-04-19 20:17 system Status resolved => closed