Tested less versions: latest official windows build (v633), but also my own builds since v570 (specifically, since 26e91bd "Allow ^X to exit F mode on Windows") upto and including v635.
Tested windows versions: Windows 10 and Windows 7.
Steps to reproduce:
- Set Windows autorepeat to a high value (if win10 - via the classic control panel). I set it to the maximum, which is about 30 repeats/sec.
- Maximize the console window (
cmd.exe).
- Invoke
less -R file where file is a big file with color escape sequences.
- Hold down page-down so that it auto-repeats and pages continuously.
Expected result:
It pages till the end of the file.
Actual result:
less aborts sooner rather than later. For me that's typically after less than 10 pages.
Here's a sample C file which was highlighted using GNU source-highlite, and reproduces the issue for me:
tccgen.c.zip
Additional info:
The offending code seems to be this at os.c, which was originally added at 26e91bd:
#if MSDOS_COMPILER==WIN32C
if (win32_kbhit() && WIN32getch() == intr_char)
{
sigs |= S_INTERRUPT;
reading = 0;
return (READ_INTR);
}
#endif
If I disable this code completely, e.g. by replacing WIN32C with WIN32C_XXXBUG, then the issue goes away.
When not disabled, and when it aborts, win32_kbhit() is true, and WIN32getch() returns 0, which apparently is not intr_char (which seem to be 24 by default), so the code block of sigs |= S_INTERRUPT; etc is NOT entered, and yet less aborts.
The issue is more likely to happen with a big console window.
I'm guessing that the cause is that less renders slower than requested (high PGDN input rate, big console, slow-to-render colors), and something gets messed up, but I didn't dig deep enough to figure out what.
Another option is that it needs ungetc() to revert the WIN32getch() call, but I couldn't figure out how (i.e. which function to use to unget it). But also, WIN32getch() returning 0 also seems a bit unexpected...
Tested
lessversions: latest official windows build (v633), but also my own builds since v570 (specifically, since 26e91bd "Allow ^X to exit F mode on Windows") upto and including v635.Tested windows versions: Windows 10 and Windows 7.
Steps to reproduce:
cmd.exe).less -R filewherefileis a big file with color escape sequences.Expected result:
It pages till the end of the file.
Actual result:
lessaborts sooner rather than later. For me that's typically after less than 10 pages.Here's a sample C file which was highlighted using GNU source-highlite, and reproduces the issue for me:
tccgen.c.zip
Additional info:
The offending code seems to be this at
os.c, which was originally added at 26e91bd:If I disable this code completely, e.g. by replacing
WIN32CwithWIN32C_XXXBUG, then the issue goes away.When not disabled, and when it aborts,
win32_kbhit()is true, andWIN32getch()returns0, which apparently is notintr_char(which seem to be 24 by default), so the code block ofsigs |= S_INTERRUPT;etc is NOT entered, and yetlessaborts.The issue is more likely to happen with a big console window.
I'm guessing that the cause is that
lessrenders slower than requested (high PGDN input rate, big console, slow-to-render colors), and something gets messed up, but I didn't dig deep enough to figure out what.Another option is that it needs
ungetc()to revert theWIN32getch()call, but I couldn't figure out how (i.e. which function to use to unget it). But also,WIN32getch()returning 0 also seems a bit unexpected...