SublimeTextXdebug icon indicating copy to clipboard operation
SublimeTextXdebug copied to clipboard

Incorrect xdebug response length checking

Open pzajac2 opened this issue 9 years ago • 1 comments

During breakpoint i've exception in Sublime Console and xdebug tabs (context, stack) stays empty.

Exception in thread Thread-11:
Traceback (most recent call last):
  File "./threading.py", line 901, in _bootstrap_inner
  File "C:\Users\pzaja_000\AppData\Roaming\Sublime Text 3\Packages\SublimeTextXdebug-master\xdebug\session.py", line 148, in run
    self.execute(self.get_option('command'))
  File "C:\Users\pzaja_000\AppData\Roaming\Sublime Text 3\Packages\SublimeTextXdebug-master\xdebug\session.py", line 242, in execute
    context = self.get_context_values()
  File "C:\Users\pzaja_000\AppData\Roaming\Sublime Text 3\Packages\SublimeTextXdebug-master\xdebug\session.py", line 279, in get_context_values
    response = S.SESSION.read()
  File "C:\Users\pzaja_000\AppData\Roaming\Sublime Text 3\Packages\SublimeTextXdebug-master\xdebug\protocol.py", line 179, in read
    data = self.read_data()
  File "C:\Users\pzaja_000\AppData\Roaming\Sublime Text 3\Packages\SublimeTextXdebug-master\xdebug\protocol.py", line 172, in read_data
    raise ProtocolException("Length mismatch encountered while reading the Xdebug message")
SublimeTextXdebug-master.xdebug.protocol.ProtocolException: Length mismatch encountered while reading the Xdebug message

It's seems that plugin incorrectly checks response lenght. I've modified code in protocol.py:

        debug('LEN1: %d' % int(length)) # added by me
        debug('LEN2: %d' % len(message)) # added by me

        if int(length) == len(message):
            return message
        else:
            raise ProtocolException("Length mismatch encountered while reading the Xdebug message")

In xdebug.log i see:

[03/05/2015 11:09:02AM] DEBUG - LEN1: 63033
[03/05/2015 11:09:02AM] DEBUG - LEN2: 63025

...and plugin raises exception. I thinks that happens due to non-latin characters in xdebug response.

pzajac2 avatar Mar 05 '15 10:03 pzajac2

Thanks @pzajac2! After a whole day of searching "why Xdebug Context is empty", your finding is exactly the answer. So it happens I have an associative array that contains the word, α (alpha), which breaks the Xdebug Context.

jiaming10 avatar Mar 22 '16 02:03 jiaming10