martomo / SublimeTextXdebug

Xdebug debugger client for Sublime Text
MIT License
564 stars 89 forks source link

Incorrect xdebug response length checking #136

Open pzajac2 opened 9 years ago

pzajac2 commented 9 years ago

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.

jiaming10 commented 8 years ago

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.