Skip to content

Remote process picking appears to be broken. #13791

Closed

Description

@mjrist

Environment

  • OS and version: Dev container: Ubuntu 24.04.1 LTS
  • VS Code: 1.102.2
  • C/C++ extension: 1.26.3
  • OS and version of remote machine (if applicable): Application container also running Ubuntu 24.04.1 LTS
  • GDB / LLDB version: GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git

Bug Summary and Steps to Reproduce

Bug Summary:

remote-attach shows me the error "file name too long: unknown". See logs below.

It seems like it is quoted incorrectly and interpreting the entire string as the executable. I think it would work if the single quotes were removed from /bin/sh -c ...

Debugger Configurations

{
            "name": "Remote Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "/app/myapp",
            "pipeTransport": {           
                "pipeProgram": "kubectl",
                "pipeArgs": ["exec", "-i", "${input:pickPod}", "--"],
                "debuggerPath": "/usr/bin/gdb"                               
            }
        }

Debugger Logs

error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "0288b51eedf9cbcb9fc25a591c73fa017d196be8409a7e2f91d201265106bf54": OCI runtime exec failed: exec failed: unable to start container process: exec: "/bin/sh -c \"uname && if [ $(uname -o) = \\\"Toybox\\\" ] ; then ps -A -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \\\"Linux\\\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \\\"Darwin\\\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi\"": stat /bin/sh -c "uname && if [ $(uname -o) = \"Toybox\" ] ; then ps -A -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Linux\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Darwin\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi": file name too long: unknown
Command failed: "kubectl" "exec" "-i" "myapp-cb4ddbd89-pkt2s" "--" '/bin/sh -c "uname && if [ $(uname -o) = \"Toybox\" ] ; then ps -A -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Linux\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Darwin\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi"'
error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "0288b51eedf9cbcb9fc25a591c73fa017d196be8409a7e2f91d201265106bf54": OCI runtime exec failed: exec failed: unable to start container process: exec: "/bin/sh -c \"uname && if [ $(uname -o) = \\\"Toybox\\\" ] ; then ps -A -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \\\"Linux\\\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \\\"Darwin\\\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi\"": stat /bin/sh -c "uname && if [ $(uname -o) = \"Toybox\" ] ; then ps -A -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Linux\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Darwin\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi": file name too long: unknown

Other Extensions

No response

Additional Information

No response

Activity

  1. sean-mcmanus commented on Jul 30, 2025

    @sean-mcmanus
    Contributor

    Matt (@mjrist) Do you know if this is a regression starting with 1.26.3?

  2. sean-mcmanus commented on Jul 30, 2025

    @sean-mcmanus
    Contributor
  3. mjrist commented on Jul 30, 2025

    @mjrist
    ContributorAuthor

    @mjrist Do you know if this is a regression starting with 1.26.3?

    Doesn't seem like it. Same issue in 1.25.3. Also tried 1.21.6. Like you point out, no recent changes to that code.

    If I just run the command from the terminal (bash) I get the same error.

    "kubectl" "exec" "-i" "myapp-cb4ddbd89-pkt2s" "--" '/bin/sh -c "uname && if [ $(uname -o) = \"Toybox\" ] ; then ps -A -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Linux\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Darwin\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi"'
    

    If I remove the single quotes around the command passed to exec, it works (running in the terminal):

    "kubectl" "exec" "-i" "myapp-cb4ddbd89-pkt2s" "--" /bin/sh -c "uname && if [ $(uname -o) = \"Toybox\" ] ; then ps -A -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Linux\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; elif [ $(uname) = \"Darwin\" ] ; then ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi"
    
  4. mjrist commented on Jul 30, 2025

    @mjrist
    ContributorAuthor

    Alright, found a work around.

    kubectl exec does not like the quoted string, but sh -c is fine with it. If I change my pipe args to "pipeArgs": ["exec", "-i", "${input:pickPod}", "--", "/bin/sh", "-c"] then it is happy as the string gets passed to sh -c

    This does mean that I get an extra process when debugging (not that it matters...)
    Image

    Using straight kubectl exec it would just start gdb:
    Image

    Also, I discovered that starting gdb with kubectl exec has the same problem with the quoted command. However using "quoteArgs": "false" fixes this. It seems to me that if quoteArgs is false the process picker ought to also skip quoting the args. If that were the case, I could just use kubectl exec without additionally invoking sh.

  5. moved this from Done to Pull Request in cpptoolson Jul 30, 2025
  6. moved this from Pull Request to Done in cpptoolson Jul 31, 2025
  7. sean-mcmanus commented on Aug 7, 2025

    @sean-mcmanus
    Contributor
  8. mjrist commented on Aug 7, 2025

    @mjrist
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugdebuggerhelp wantedCan be fixed in the public (open source) repo.

Type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions