Skip to content
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

Cannot debug on MacOS when long environment variable is set (circa 2000 characters) #6874

Closed
rockdreamer opened this issue Jan 30, 2021 · 11 comments · May be fixed by #11566
Closed

Cannot debug on MacOS when long environment variable is set (circa 2000 characters) #6874

rockdreamer opened this issue Jan 30, 2021 · 11 comments · May be fixed by #11566
Labels
bug debugger investigate This issue needs to be investigated/confirmed

Comments

@rockdreamer
Copy link

Type: Debugger

Describe the bug

  • OS and Version: MacOS 10.15
  • VS Code Version: 1.52.1
  • C/C++ Extension Version: 1.1.3
  • Other extensions you installed (and if the issue persists after disabling them): issue persists after disabling every other extension
  • A clear and concise description of what the bug is.

First of all thank you for the great product! 💯 👍 !!!!

To Reproduce
Please include a code sample and launch.json configuration.
Steps to reproduce the behavior:

  1. Create a .env file with a long environment variable. See attached file. envfile.txt
  2. Add a launch.json using the .env file that runs any executable. See example launch.json.txt
  3. Launch entry
  4. See regrettable error message pop up on screen
    image

Additional context
Problem occurs even if I set the environment directly in the configuration. It appears that the message is truncated on its way to the underlying engine.
The issue goes away if I remove one character from the attached envFile.

According to DevToolsSecurity -status, Developer mode is currently enabled.

Debug Console output:
`--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (327) <-1008-interpreter-exec console "settings set target.env-vars DYLD_LIBRARY_PATH=\"/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexactivator/3.12.1///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexfloatclient/4.3.10///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openscenegraph/3.6.3///package/496c694a158600e9374d6f4ff119717cb4329963/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/cryptopp/8.2.0/bincrafters/stable/package/65b4eeac84096d8cf1459a798c07440f6ed79e3a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/ccdcsqlite3/3.17.0///package/863dc29f74a5b1da8915b98a222bbcc45e90ce46/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gtest/1.8.1///package/89353b6e006c1d513020e00f56b6b24bd8163e5d/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gsoap/2.8.109///package/4bca0050b2fbb691fd93ec5a87cdc464b4cbf097/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxl/3.8.2.0///package/fbc9f5348579d8c9e4ba5a008d95280b87ce1e8a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/inchi/1.04///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/rstatistics/2.11.1///package/743cf0321be3152777da4d05247a66d1552e70a2/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/csdprotobufs/1.0.117///package/b09b1606af513081c72c033281d3a8b666c2bc74/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/mariadb-connector-c/3.1.11///package/e5367c0e9e837dbe471cdcb23927a9ee1c3a2150/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/pcre/8.41///package/01ffead025ec90a93de23fa980552b4c33618f62/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openssl/1.1.1i///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxml2/2.9.10///ssssssss\""\n"},"seq":76}

1: (327) <-1008-interpreter-exec console "settings set target.env-vars DYLD_LIBRARY_PATH="/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexactivator/3.12.1///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexfloatclient/4.3.10///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openscenegraph/3.6.3///package/496c694a158600e9374d6f4ff119717cb4329963/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/cryptopp/8.2.0/bincrafters/stable/package/65b4eeac84096d8cf1459a798c07440f6ed79e3a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/ccdcsqlite3/3.17.0///package/863dc29f74a5b1da8915b98a222bbcc45e90ce46/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gtest/1.8.1///package/89353b6e006c1d513020e00f56b6b24bd8163e5d/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gsoap/2.8.109///package/4bca0050b2fbb691fd93ec5a87cdc464b4cbf097/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxl/3.8.2.0///package/fbc9f5348579d8c9e4ba5a008d95280b87ce1e8a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/inchi/1.04///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/rstatistics/2.11.1///package/743cf0321be3152777da4d05247a66d1552e70a2/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/csdprotobufs/1.0.117///package/b09b1606af513081c72c033281d3a8b666c2bc74/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/mariadb-connector-c/3.1.11///package/e5367c0e9e837dbe471cdcb23927a9ee1c3a2150/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/pcre/8.41///package/01ffead025ec90a93de23fa980552b4c33618f62/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openssl/1.1.1i///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxml2/2.9.10///ssssssss""

1: (328) STDERR: MI: Error: Command Args. Validation failed. Mandatory args not found: interpreter, command. Not all arguments or options were recognised: console "settings set target.env-vars DYLD_LIBRARY_PATH="/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexactivator/3.12.1///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/lexfloatclient/4.3.10///package/98693e2cd8e6a5b0612dd5b0ae31d688615da5b9/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openscenegraph/3.6.3///package/496c694a158600e9374d6f4ff119717cb4329963/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/cryptopp/8.2.0/bincrafters/stable/package/65b4eeac84096d8cf1459a798c07440f6ed79e3a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/ccdcsqlite3/3.17.0///package/863dc29f74a5b1da8915b98a222bbcc45e90ce46/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gtest/1.8.1///package/89353b6e006c1d513020e00f56b6b24bd8163e5d/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/gsoap/2.8.109///package/4bca0050b2fbb691fd93ec5a87cdc464b4cbf097/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxl/3.8.2.0///package/fbc9f5348579d8c9e4ba5a008d95280b87ce1e8a/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/inchi/1.04///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/rstatistics/2.11.1///package/743cf0321be3152777da4d05247a66d1552e70a2/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/csdprotobufs/1.0.117///package/b09b1606af513081c72c033281d3a8b666c2bc74/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/mariadb-connector-c/3.1.11///package/e5367c0e9e837dbe471cdcb23927a9ee1c3a2150/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/pcre/8.41///package/01ffead025ec90a93de23fa980552b4c33618f62/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/openssl/1.1.1i///package/4968af75f822d4742c208cdc37bfd4618fba68cd/lib:/Users/vagrant/builds/ninja-release/conan-home/.conan/data/libxml2/2.9.10///ssssssss"`

Hopefully this might be of assistance
--> E (output): {"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/DebugCompleted","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"16.5.11030.1","VS.Diagnostics.Debugger.HostVersion":"16.5.11030.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.DebugCompleted.BreakCounter":0}},"seq":111}

@thirtytwobits
Copy link

I'm seeing this on OSX using lldb but it's not length it's escaping. The environment variables can, apparently, contain some text that is not properly escaped when invoking lldb. By clearing my environment it seems to work:

"environment": "",

@rockdreamer
Copy link
Author

Hi Scott, I'm not sure the behaviour you're seeing is the same issue. That would conflict with two facts:

  1. When I remove the last s from the DYLD_LIBRARY_PATH, the debugger starts, so I can see length triggering the issue, not character composition
  2. The characters in the path are all produced by conan or contain a build path in the home directory and they are either alphanumeric ([1-2a-zA-Z]), a forward slash to separate directories or the path separating colon.

I can see how string escaping might be an issue in it's own right, there's very little in the way of public documentation of dotenv files. I think we'll both be better served if you create a separate bug report with a more specific test case, mentioning the specific characters that are creating the issue for you. (I'm sure it will open a nasty can of worms, requiring - gasp! - developers of multiple IDEs communicate amongst themselves :) )

@WardenGnaw
Copy link
Member

Do you have externalConsole: true in your launch.json?

I couldn't find it at the moment, but I'll see if I can later, but I believe lldb-mi tries to pass all the env variables as a command line, so it is limited to the terminal input's limitation.

@WardenGnaw WardenGnaw added bug debugger investigate This issue needs to be investigated/confirmed labels Feb 3, 2021
@rockdreamer
Copy link
Author

Hi @WardenGnaw, thank you for looking into this.
I just tried and I get the same outcome with externalConsole set to either true or false.
I wondered if there were settings set that might affect this but this is all I have in $HOME/Library/Application Support/Code/User/settings.json

{
    "terminal.integrated.scrollback": 50000
}

@github-actions
Copy link

github-actions bot commented Aug 3, 2021

This issue has been closed automatically because it has not had recent activity.

@github-actions github-actions bot closed this as completed Aug 3, 2021
@rockdreamer
Copy link
Author

Crickets...

@felipeek
Copy link

I'm having the exact same issue!

@felipeek
Copy link

@WardenGnaw can you please re-open this bug? The issue is still there and it is very easy to reproduce. The debugger is not usable when the environment array is too long

ylatuya added a commit to ylatuya/lldb-mi that referenced this issue Nov 23, 2021
Increase the command buffer size x10 to support passing long environment
variables.  This is required in projects like GStreamer requiring to
setup env variables like GST_PLUGIN_PATH with several directories in
order to be able to debug without having to install into a prefix, which
takes a long time and slows down the development cycle.

microsoft/vscode-cpptools#8411
microsoft/vscode-cpptools#6874
ylatuya added a commit to ylatuya/lldb-mi that referenced this issue Nov 23, 2021
Increase the command buffer size x10 to support passing long environment
variables.  This is required in projects like GStreamer requiring to
setup env variables like GST_PLUGIN_PATH with several directories in
order to be able to debug without having to install into a prefix, which
takes a long time and slows down the development cycle.

microsoft/vscode-cpptools#8411
microsoft/vscode-cpptools#6874
@ylatuya
Copy link

ylatuya commented Nov 23, 2021

I stumbled into the same issue and following @WardenGnaw I created a new PR that fixes the issue: lldb-tools/lldb-mi#87

To test it, follow the instructions to build lldb-mi from https://github.com/lldb-tools/lldb-mi#building-against-custom-lldb and add to your launch.json "miDebuggerPath": "/path/to/lldb-mi/build/src/lldb-mi"

ylatuya added a commit to ylatuya/lldb-mi that referenced this issue Sep 27, 2023
Replace the command buffer with a std::string to support reading
arbitrary command line lengths. This is required in projects like
GStreamer that setup long environment variables like GST_PLUGIN_PATH
with several directories on it.

microsoft/vscode-cpptools#8411
microsoft/vscode-cpptools#6874
ylatuya added a commit to ylatuya/lldb-mi that referenced this issue Sep 27, 2023
Replace the command buffer with a std::string to support reading
arbitrary command line lengths. This is required in projects like
GStreamer that setup long environment variables like GST_PLUGIN_PATH
with several directories on it.

microsoft/vscode-cpptools#8411
microsoft/vscode-cpptools#6874
sunshaoce pushed a commit to lldb-tools/lldb-mi that referenced this issue Oct 17, 2023
Replace the command buffer with a std::string to support reading
arbitrary command line lengths. This is required in projects like
GStreamer that setup long environment variables like GST_PLUGIN_PATH
with several directories on it.

microsoft/vscode-cpptools#8411
microsoft/vscode-cpptools#6874
ylatuya added a commit to ylatuya/vscode-cpptools that referenced this issue Oct 23, 2023
@ylatuya
Copy link

ylatuya commented Oct 23, 2023

This issue should be reopened, since in order to fix it, it requires an lldb-mi hash bump to include the fix in lldb-tools/lldb-mi#87

@sean-mcmanus sean-mcmanus reopened this Oct 23, 2023
WardenGnaw pushed a commit that referenced this issue Nov 6, 2023
Copy link

This issue has been closed as lower priority. We're sorry if this issue still impacts you but unfortunately we're not able to address this. We will accept a pull request from the community if it's applicable for this issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug debugger investigate This issue needs to be investigated/confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants