I just pushed out a bug fix to sam (not samterm),
both on sources and in plan9port.

This sam should fix a 15-year-old protocol bug
in which the terminal and the sam could get
out of sync during long remote editing sequences.

For example, if you did a global search and
replace in a very large file, it could, very rarely,
happen that afterward the terminal would have
incorrect file addresses for the data it was
displaying, so that subsequent mouse-and-keyboard
edits to the file didn't go where you indicated.

Alternate manifestations of the bug include
individual sam file windows wedging and becoming
unusable (but you could close and reopen the file)
or sam panics.

Rob says he has been getting reports about this
bug infrequently for a long time, but never with
enough information to track it down. I saw the
symptoms twice in my own editing sessions in the
last six months, but not with enough information
to reconstruct what had happened.

Geoff Collyer wins the prize for the being the
lucky owner of a panicked sam process in which
the bug can be seen chewing on the data structures.

Obviously, there is the potential that I have
introduced a new bug with my fix. The protocol code
code is historically quite subtle, but I have carefully
reasoned through convincing myself that the changes
are correct, Rob says they are at least believable,
and I have tested them in some unforgiving conditions
that should have teased out any mistakes.

Please let me know if you see any odd behavior or other
problems from sam.