Skip to content

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

Closed as not planned

Description

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}

Activity

  1. thirtytwobits commented on Jan 30, 2021

    @thirtytwobits

    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": "",
    
  2. rockdreamer commented on Jan 31, 2021

    @rockdreamer
    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 :) )

  3. WardenGnaw commented on Feb 3, 2021

    @WardenGnaw
    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.

  4. rockdreamer commented on Feb 3, 2021

    @rockdreamer
    Author

    Hi Andrew Wang (@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
    }
    
  5. github-actions commented on Aug 3, 2021

    @github-actions

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

  6. rockdreamer commented on Aug 3, 2021

    @rockdreamer
    Author

    Crickets...

  7. felipeek commented on Nov 12, 2021

    @felipeek

    I'm having the exact same issue!

  8. felipeek commented on Nov 12, 2021

    @felipeek

    Andrew Wang (@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

  9. ylatuya commented on Nov 23, 2021

    @ylatuya

    I stumbled into the same issue and following Andrew Wang (@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"

  10. added a commit that references this issue on Oct 23, 2023
    b15a9de
  11. ylatuya commented on Oct 23, 2023

    @ylatuya

    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

  12. added a commit that references this issue on Nov 6, 2023
    62614d8
  13. github-actions commented on Apr 21, 2024

    @github-actions

    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.

  14. H-G-Hristov commented on Sep 23, 2025

    @H-G-Hristov

    Can we get this fixed finally?

  15. added 2 commits that reference this issue on Oct 3, 2025
    2f2ef76
    6113e94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdebuggerinvestigate: reproThis issue's repro steps needs to be investigated/confirmed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions