Explanation of the Bug In BX Beta Revision 2644
Doug Lee
August 9, 2024

This document explains a bug that existed in the beta version of BX that was available on my website from 7:00 PM August 2 through noon on August 9, 2024. The only affected BX revision is revision 2644. The bug did not affect any official BX release and would only affect BX users who, within that time frame, either used the BX Update feature to obtain revision 2644 or ran the beta installer, which is separate from the official release installer, to install that revision. To check your BX revision, activate BX by typing Insert+Space twice quickly, then Insert+Q to check the revision number, and finally Insert+Space twice quickly again to turn BX off.

Background

BX includes a few "Quick Key" commands that allow listing, switching among, and renumbering of Windows tasks. The code for this system keeps a copy of the task list on disk so that a JAWS restart will not cause the tasks to be renumbered. The format of this task list changed slightly in BX revision 2642 (the latest formal release at this writing), and this change exposed a few bugs that could cause arbitrarily high numbers to be assigned to tasks.

Problem Description

On August 2, 2024, I posted, as a beta and not a release, BX revision 2644. This beta revision contained the following changes as compared to the official BX revision 2642 release:

  1. Fixes to bugs in the task list code for BX QuickKey commands like QuickKey W, and QuickKey followed by digits, that sometimes caused new tasks/windows to be assigned unusually high task numbers. This change did not cause any problems.
  2. Additional code to clean up any saved task lists that contained extra slots at the end of the list, so that new tasks after a JAWS restart would also not get assigned oddly high task numbers. This change contained the bug described shortly.

The first item did not cause any problems; but the second, in some cases, could result in an infinite loop. The technical cause of the bug was an unexpected behavior of the built-in JAWS substring function.

Impact

Any user encountering this bug would experience a JAWS hang, and either an automatic JAWS restart or a need to restart JAWS manually, after using one of the Quick Key commands for managing tasks by number. For example, typing ] W might hang JAWS. These commands might work for most users and for most cases, but any failure resulting from this bug would cause this hang.

Solution

Perform the same step that resulted in the upgrade to BX revision 2644, now to replace it with revision 2645 (or later, if a later revision is posted before this step is performed):

Restart JAWS immediately after updating BX, to be sure that the update takes effect.

Technical Details

The JAWS substring function, at least as tested under JAWS 2024, surprised this script author by returning non-null string values for improper values of its second parameter. Specifically, substring(s, index, 1) returns the first character of s for values of index that are 0 or negative. This author expected substring(s, 0, 1) to return the null string. The result was a loop in BX that would never terminate for some values of s.