On 09/12/2012 11:02 PM, Eli Zaretskii wrote: > The reason for the assertion violation is the assertion in > marker_position: > > eassert (BUF_BEG (buf) <= m->charpos && m->charpos <= BUF_Z (buf)); > > This was introduced recently by Dmitry, in revision 108906. A similar > assertion was added to marker_byte_position. > > Dmitry, why did you add them? Who said that a marker cannot > legitimately have a position outside of its buffer's range of > character positions? IIUC marker can have out-of-buffer-range position, but only somewhere in the middle of an insertion/deletion/replace operation; out-of-range position should be detected and immediately fixed by adjust_markers_for_{delete,insert,replace}. BTW, look at this code from replace_range: /* Adjust the overlay center as needed. This must be done after adjusting the markers that bound the overlays. */ adjust_overlays_for_delete (from, nchars_del); adjust_overlays_for_insert (from, inschars); /* Adjust markers for the deletion and the insertion. */ if (markers) adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, inschars, outgoing_insbytes); The comment explicitly says that overlays should be adjusted _after_ markers, but the code adjusts overlays and then markers :-(. Since an overlays are bounded by markers, the comment looks correct but the code isn't. I suppose that the code snippets above should be swapped. Dmitry