Commit
7bba6232 (vss: Mmap audio files using MAP_POPULATE.) introduced
read-ahead for chunks of the mmapped audio file. However, it missed
the fact that for ogg streams chunk 0 is created on the fly and stored
in a dynamically allocated buffer. Read-ahead on this buffer is likely
to access memory not owned by the process and might lead to a segfault.
Fix this bug by not performing read-ahead for chunk zero.
senders[i].send(mmd->current_chunk, mmd->chunks_sent,
buf, len, vsst->header_buf, vsst->header_len);
}
- mmd->chunks_sent++;
- mmd->current_chunk++;
/*
* Prefault next chunk(s)
*
* eliminate the delays completely. Moreover, it is supported
* only on Linux. So we do our own read-ahead here.
*/
- buf += len;
- for (i = 0; i < 5 && buf < vsst->map + mmd->size; i++) {
- __a_unused volatile char x = *buf;
- buf += 4096;
+ if (mmd->current_chunk > 0) { /* chunk 0 might be on the heap */
+ buf += len;
+ for (i = 0; i < 5 && buf < vsst->map + mmd->size; i++) {
+ __a_unused volatile char x = *buf;
+ buf += 4096;
+ }
}
+ mmd->chunks_sent++;
+ mmd->current_chunk++;
}
}