{"record":{"id":"4e167ffac2843e26","repo":"go-delve/delve","slug":"must-specify-at-least-one-argument-for-qrrcmd","errorCode":null,"errorMessage":"must specify at least one argument for qRRCmd","messagePattern":"must specify at least one argument for qRRCmd","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/gdbserial/gdbserver_conn.go","lineNumber":1196,"sourceCode":"\treturn sp, nil\n}\n\n// restart executes a 'vRun' command.\nfunc (conn *gdbConn) restart(pos string) error {\n\tconn.outbuf.Reset()\n\tfmt.Fprint(&conn.outbuf, \"$vRun;\")\n\tif pos != \"\" {\n\t\tfmt.Fprint(&conn.outbuf, \";\")\n\t\twriteAsciiBytes(&conn.outbuf, []byte(pos))\n\t}\n\t_, err := conn.exec(conn.outbuf.Bytes(), \"restart\")\n\treturn err\n}\n\n// qRRCmd executes a qRRCmd command\nfunc (conn *gdbConn) qRRCmd(args ...string) (string, error) {\n\tif len(args) == 0 {\n\t\tpanic(\"must specify at least one argument for qRRCmd\")\n\t}\n\tconn.outbuf.Reset()\n\tfmt.Fprint(&conn.outbuf, \"$qRRCmd\")\n\tfor i, arg := range args {\n\t\tfmt.Fprint(&conn.outbuf, \":\")\n\t\tif i == 0 && (conn.newRRCmdStyle || conn.threadSuffixSupported) {\n\t\t\t// newer versions of RR require the command to be followed by a thread id\n\t\t\t// and the command name to be unescaped.\n\t\t\tfmt.Fprintf(&conn.outbuf, \"%s:-1\", arg)\n\t\t} else {\n\t\t\twriteAsciiBytes(&conn.outbuf, []byte(arg))\n\t\t}\n\t}\n\tresp, err := conn.exec(conn.outbuf.Bytes(), \"qRRCmd\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdata := make([]byte, 0, len(resp)/2)","sourceCodeStart":1178,"sourceCodeEnd":1214,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/gdbserial/gdbserver_conn.go#L1178-L1214","documentation":"qRRCmd sends the 'qRRCmd' packet used to query/mutate mozilla rr state. It requires at least one argument because the packet format joins arguments with ':' after the command name; calling it with zero arguments would produce a malformed packet, so it panics instead.","triggerScenarios":"Calling conn.qRRCmd() with no variadic arguments from internal code (e.g. rr checkpoint/readPacket helpers built incorrectly).","commonSituations":"Custom rr integration code, patched forks of delve, or new features issuing qRRCmd queries with a dynamically built (and accidentally empty) argument list.","solutions":["Always pass at least one argument, e.g. conn.qRRCmd(\"checkpoints\")","Audit the call site that builds the args slice; guard against len(args)==0 before calling","If the command legitimately takes no args, send a different packet or a default argument supported by rr"],"exampleFix":"// before\nconn.qRRCmd(args...)\n// after\nif len(args) == 0 {\n    return \"\", errors.New(\"qRRCmd requires arguments\")\n}\nconn.qRRCmd(args...)","handlingStrategy":"validation","validationCode":"if len(args) == 0 {\n    return errors.New(\"qRRCmd requires at least one argument\")\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil { err = fmt.Errorf(\"qRRCmd: %v\", r) }\n}()","preventionTips":["Guard variadic arg slices before packet construction","Consult rr's qRRCmd documentation for valid argument forms","Add unit tests for packet builders with empty inputs"],"tags":["gdbserial","rr","panic","argument-validation"],"backgroundTag":"gdb-protocol-invariant-violation","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}