Sublime Forum

Floating point related UI hang with Windows build 3143

#1

I’m using a 64-bit build of Sublime Text 3143 on Windows 7, and occasionally the editor hangs when connecting to my desktop session through Windows Remote Desktop. In particular, the UI thread gets stuck in a loop while performing some floating-point operations. The pseudocode of the loop at sub_13F9E70C0 is as follows:

int __attribute__((ms_abi)) sub_13F9E70C0(double a1, double a2, double a3, int a4) {
  char v5;
  int result;

  v5 = sub_13F9E6EF4(a1, a2, a3, a4);
  do {
    a1 = a1 + 0.03333333333333333;
    result = sub_13F9E6EF4(a1, a2, a3, a4);
  } while ( (char)result == v5 );
  return result;
}

int __attribute__((ms_abi)) sub_13F9E6EF4(double a1, double a2, double a3, int a4) {
  ...
  double v18 = floor(v8 * 255.0 + 0.5);
  result = (int)v18 & 0xF0;
  if ( (char)(int)v18 == -1 )
    result = (unsigned char)(int)v18;
  return result;
}

The problem is that in sub_13F9E6EF4, v18 = 255.0, so (char)(int)v18 == -1 is true, and 255 is returned. Then, in sub_13F9E70C0, v5 = 255, so (char)result == 255 is true, and the loop endlessly repeats. At the top level, this loop is called (through some intermediate functions) from a timer callback managed by SetTimer()/KillTimer().

I suspect this has something to do with the operating system changing the size of the virtual desktop when I connect, and it’s triggering some floating-point instability (or a logic error involving v18) in UI-related code.

Let me know if you need more information. I have a crash dump available, but I’m not willing to post it publicly.

0 Likes

#2

Thanks for the detailed report, this will be fixed in the next build.

The root cause is a logic error: I believe that Windows Remote Desktop will disable caret blinking by default, and if this is reported to Sublime Text at the wrong time, then it will enter into an infinite loop when trying to determine when the next time the caret needs to be updated.

As a work around, you could manually disable caret blinking using the “caret_style”: “solid” setting, which will ensure we never get into that state, or manually set a blink interval via “caret_blink_interval”: 0.5.

1 Like

#3

Thanks for the quick fix!

0 Likes