0

My Visual Studio debugger is not working properly and I get "Error evaluating code" for everything (see the variable value, 1+1, and any other PHP code). All fixes are not working.

I tried with:

VS 2017/2019/2022

PHP 7.4, PHP8.0, PHP 8.1, PHP 8.2

I tried multiple configurations of php.ini

I'm using XAMPP 3.3.0 on W10.

Xdebug log show errors like this when I try to run any PHP code in the immediate window:

[8796] [Step Debug] <- eval -i 16-0 -- ZXZhbCgidHJ5IHsgcmV0dXJuICAxICsgMTsgfWNhdGNoIChUaHJvd2FibGUgJHQpeyByZXR1cm4gbmV3IERldnNlbnNlRXZhbEVycm9yKCR0LT5nZXRNZXNzYWdlKCkpO31jYXRjaCAoRXhjZXB0aW9uICRlKXsgcmV0dXJuIG5ldyBEZXZzZW5zZUV2YWxFcnJvcigkZS0+Z2V0TWVzc2FnZSgpKTt9Iik7
[8796] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="16-0" status="break" reason="ok"><error code="206"><message><![CDATA[error evaluating code]]></message></error></response>

I'm trying to solve this issue by 1 year. No success.

1 Answer 1

2

The base64 decode of that string results in:

eval("try { return  1 + 1; }catch (Throwable $t){ return new DevsenseEvalError($t->getMessage());}catch (Exception $e){ return new DevsenseEvalError($e->getMessage());}");

Which can't really work, as you haven't escaped the $t in catch (Throwable $t) for example, and that throws a warning and a parse error when you run this with normal PHP:

Warning: Undefined variable $t in /tmp/foo.php on line 2

Warning: Undefined variable $t in /tmp/foo.php on line 2

Warning: Attempt to read property "getMessage" on null in /tmp/foo.php on line 2

Warning: Undefined variable $e in /tmp/foo.php on line 2

Warning: Undefined variable $e in /tmp/foo.php on line 2

Warning: Attempt to read property "getMessage" on null in /tmp/foo.php on line 2

Parse error: syntax error, unexpected token ")" in /tmp/foo.php(2) : eval()'d code on line 1

It seems likely that Devsense (I don't know what that is) is throwing a spanner in the works, as it literally just should send MSsx (base 64 encoded form of 1+1).

Sign up to request clarification or add additional context in comments.

4 Comments

I just typed 1 + 1 in immediate window. The other code (try { ... }...) is added by Visual Studio or PHP tools. Are you telling this? The bug is from Visual Studio or PHP Tools? Thank you!
Yes, exactly. I only have VS Code + "PHP Debug" and "PHP Extension Pack" installed, and that generates: eval -i 14 -- JEdMT0JBTFNbJ2V2YWxfY2FjaGUnXVsnNjQyZTAxNDUtYzFmYS00YjdmLWFjZDAtZDhlYjExYTZlY2JhJ109MSsx which translates to a correct $GLOBALS['eval_cache']['642e0145-c1fa-4b7f-acd0-d8eb11a6ecba']=1+1.
I have the same issue you described I contacted Devsense and Devtools. Thanks!
yes, that's our bug(Devsense) introduced in a recent version. Sorry about that! The fixed version is available now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.