I'm not top posting.
I think this is quite important...
Explaining in theory is very complicated - an example should clarify.
This makes lilypond crash and make no output.
<<
\new Voice = "a" {
\new Voice = "b" {c2( d2)}
r4 r4 c2
}
\new Lyrics \lyricsto "b" {
\set associatedVoice = "a" Aaa __
Bbb
}
If you change "r4 r4" with "r2", lilypond works - it crashes only with two
rests in that point.
It works also if you remove the melismata or the extender on the "Aaa".
Obviously if you add some music before the "b" Voice the Lyrics can be
associated with "a" and then switch to "b", but lilypond crashes when
trying to print "Bbb" in the "a" Voice.
This seems to be fixed if you add another Voice context (and name it)
on the "r4 r4 c2" bar and switch to this Voice rather than the main.