On Monday 04 August 2003 10:39, Chris Cannam wrote:
> I haven't seen this one myself, but I had a report (off-list) at the
> weekend from Frank Pirrone with much the same stack trace, for a crash
> when importing a MIDI file. He had wondered (from reading on the list
> about crashes on startup) whether it was an ALSA problem and had tried
> ALSA 0.9.4 and 0.9.2 just to check -- I don't think it looks like an
> ALSA problem myself, but there you go.
It wasn't an ALSA problem, I've committed a fix. The crash was due to the fact
that in some cases we were memcpy()ing more data than the mmapped buffer
could hold. We compute the size of the mmapped buffer by multiplying the
number of events with their size (and the nb of repeats, but that's
irrelevant here). But to dump a segment on an mmapped buffer we first fill a
QByteArray with MappedEvents, and then memcpy the QByteArray's raw data to
the mmapped buffer, taking the size of that data, not the one we computed.
The reason we do this is that the QByteArray is normally smaller than the size
we computed for the mmapped buffer, because we only stuff note events into
the QByteArray (while the mmapped buffer size was calculated as
sizeof(MappedEvent) * total_nb_of_events_in_segment_including_non_note_ones).
But the QByteArray, like all sensible arrays, can overallocate and therefore
get *larger* than the size of its actual data, and, indeed, larger than the
mmapped buffer.
So I've fixed that by rechecking the mmapped buffer size prior to actually
memcpy()ing the data. That's more wasteful, but also quicker than trying to
trim the QByteArray's raw data. I obviously thought of memcpy()ing using the
min(mmapped buffer size, QByteArray's data size), but I'm not sure how far we
can trust that we'd get all the array's data by doing this (it's supposed to
be contiguous, but...).
--
Guillaume.
http://www.telegraph-road.org
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Rosegarden-devel mailing list
[EMAIL PROTECTED] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel