Hi Dmitry!
The problem only occurs under certain circumstances. `window-end' must called from a post-command hook and the command that started it must be bound to a key (not using M-x). Also, sometimes it seems to work correctly, sometimes not, like every second time. (Take "must" with a grain of salt, it might be possible to trigger the bug under other circumstances as well.)
I have attached a piece of lisp code which basically is the follow-mode code plus log commands, so that you clearly can see the return value of different functions, including the call to `windows-end'. I'm sure it would be possible to cut down the code to a minimal, now when we know that it's `window-end' that returns the incorrect value. (The logs I referred to in the previous mails were generated by this package.) I'm not familiar with the bug tracking system, but feel free to add this code to it.
In case you are not familiar with follow-mode, it is a package that creates the illusion that you have one large window spread out over several side-by-side windows, you can move between the windows using the normal cursor keys, and when you scroll one window, the others follow (hence the name "Follow mode"). Technically, this is accomplished by a using a post-command hook that performs all the repositioning, plus a handful of new function performing operations that didn't exist before (like scrolling X pages, where X equal the number of windows the buffer is shown in).
Do you think that you have everything that you need to find and fix the bug, or is there anything else that I can help you with?
Sincerely,
Anders Lindgren