-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected token ... in JSON at position ... #1348
Comments
@dirkseidel Can you verify the file encoding of your |
Unfortunately the fix for #1339 does not help here (and also doesn't seem to be related). Concerning the file encoding I get the following: I am running VS Code on a Mac and the remote debugging takes place with gdb on a Linux machine with SUSE Linux Enterprise Desktop 12 SP2 (x86_64). How do I get the stacktrace.txt file like in #1339? |
@dirkseidel You can get a similar logs by adding this to your launch.json
|
I have switched on engineLogging, trace and traceResponse. In addition, I also once got the following error message before the debugger aborted: |
@dirkseidel You can probably turn off engineLogging and just do trace/traceResponse. Json parsing is done for communication between our extension and VSCode so either we are sending invalid data or VSCode is. I'd like to see why the data is bad. Can you try and change the encoding for the |
language `en' is also unknown/not supported on my system. I have attached the log file The unexpected tokens all seem to be new lines in this case. |
@dirkseidel that helped figure out what the problem is. It looks like I'll take a look and see if this is something we can fix. Since I can't duplicate it, can you send me a log with the same scenario but with just |
@dirkseidel I am having trouble reproducing this issue. Can you reproduce the issue with running a simple project that has an infinite loop printing "Hello World" on the Linux box and attaching to it? |
@pieandcakes vscodeDebug.log It is not always a problem with a newline. In the second message here it is the token "i" and very often it is "C" which is the problem @WardenGnaw The simple "Hello World" doesn't cause any problems. |
@dirkseidel How are you able to determine which characters they are? Also, I don't see those errors in either of the log files you provided. Our debug adapter only sends JSON from the adapter to VS Code, so knowing what we are sending to see this error would be helpful. By going through both logs, my assumption was the '\n' character which seems to be an invalid assumption. Are you sure this JSON error is coming from our code and not your application? I see that in your debug log, that gdb is loading a json parser also. |
A popup from VSCode appears at the top of the window stating "Fehler" in red and then the error message like: The new line only shows up when pasting it in here. In the popup window it is one line and the newline looks like a whitespace character. |
@dirkseidel can you peek in the output window and see if there is a more detailed message? |
As far as I can see there is nothing to peek in. Only the message I posted already. The only thing I can do is close it with ESC or click on "Schließen" on the right of the window. |
Interesting. Do these messages get preceeded by any specific command or action that you have done? That might be our deserialization of JSON from VS Code then. Do you have any non-English characters (umlaut, ß, etc) in any of your locals or watch variables? I'm trying to figure out how I can reproduce this from my side to debug it. |
I just start the debugger with e.g. F5 and then wait. Most of the time the debugger crashes shortly after the stack trace is shown. All our variables are usually in English but of course I don't know if this is true for the whole code. |
Hello, I'm also having an issue with the debugger. I'm on Debian sid with latest updates applied. After hitting F5, generating the launch json file and updating the paths, the task fails with a message:
My launch.json contents: {
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"logging": {
"engineLogging": true
}
}
]
} The debug console only shows:
Is there anything else I can provide to help fix this issue? |
@aowrew-fp Can you see if reinstalling the extension fixes your issue? Also, when you installed Deb, which language/locale did you install it with? I haven't seen this on Debian either. We are still trying to reproduce this in house so we can debug it and see where it is failing. when you get this error above, if you go to the output window for VS Code do you see any information in there about the error? |
@pieandcakes thanks for your reply - I have tried reinstalling the plugin and reloading VSC. $ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_GB.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_GB.UTF-8
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT=en_GB.UTF-8
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL= I've recorded how the error appears, you can see here - https://vimeo.com/259658475 |
I found a reason of error "Unexpected token { in JSON at position 8." - the new version of gnome-terminal (3.27). After downgrading to version 3.24 from Ubuntu 17.10 no error occures. |
@stanf0rd Thank you for the repro. It looks like gnome-terminal 3.27 changed behavior of sending their error messages through stdout instead of stderr which is causing the debug adapter to send invalid messages to VsCode. We think we have a fix and we will create an insiders for it shortly. |
A fix is available at https://github.com/Microsoft/vscode-cpptools/releases/tag/v0.16.0-insiders2 . Let us know if there are any issues before our official release some time next week. |
Unfortunately, the fix doesn't solve the problem for me. Still getting unexpected token errors. |
@sean-mcmanus the update fixed it for me, many thanks! |
@dirkseidel So the issue that we could reproduce on Linux was that the terminal was sending data itself on stdout instead of stderr which VS Code wasn't expecting and our solution was to log it to the engine log. If you enable engine logging with Otherwise, we will need to get some more specific repro steps on Mac. |
@dirkseidel We found another place we did not redirect output. Can you try https://github.com/Microsoft/vscode-cpptools/releases/tag/v0.16.1 to see if this fixes it for you? |
Now everything seems to be fine. Thanks! |
I am using debugging by attaching to a remote program with the following entries in launch.json:
{
"name": "Debug Remote",
"type": "cppdbg",
"request": "attach",
"program": "...",
"processId": "${command:pickRemoteProcess}",
"sourceFileMap": {
"...": "..."
},
"pipeTransport": {
"pipeCwd": "/usr/bin",
"pipeProgram": "/usr/bin/ssh",
"pipeArgs": [
"..."
],
"debuggerPath": "/usr/bin/gdb"
},
"osx": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
}
After starting debugging, gdb attaches to the program, but shortly after displaying the stack trace, the debugger crashes with error messages like:
"Unexpected token C in JSON at position 2110. Der Debugadapter wird beendet."
Sometimes the token is empty and sometimes it is something different than "C". Also the position is always different. The number of those messages per start ranges from 1 to 5.
I always had this problem every once in a while, but after two or three restarts of debugging I could use it. Unfortunately, since the latest update to version 0.14.4, I have not been able to attach successfully to the program.
The text was updated successfully, but these errors were encountered: