{"record":{"id":"c6e7fd70e07882a3","repo":"golang/go","slug":"no-exit-code-in-q","errorCode":null,"errorMessage":"no exit code (in %q)","messagePattern":"no exit code \\(in %q\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"misc/go_android_exec/main.go","lineNumber":276,"sourceCode":"\t\tif err != nil {\n\t\t\treturn n, err\n\t\t}\n\t}\n\treturn n, nil\n}\n\nfunc (f *exitCodeFilter) Finish() (int, error) {\n\t// f.buf could be empty, contain a partial match of exitRe, or\n\t// contain a full match.\n\tb := f.buf.Bytes()\n\tdefer f.buf.Reset()\n\tmatch := f.exitRe.FindSubmatch(b)\n\tif len(match) < 2 || match[1] == nil {\n\t\t// Not a full match. Flush.\n\t\tif _, err := f.w.Write(b); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\treturn 0, fmt.Errorf(\"no exit code (in %q)\", string(b))\n\t}\n\n\t// Parse the exit code.\n\tcode, err := strconv.Atoi(string(match[1]))\n\tif err != nil {\n\t\t// Something is malformed. Flush.\n\t\tif _, err := f.w.Write(b); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\treturn 0, fmt.Errorf(\"bad exit code: %v (in %q)\", err, string(b))\n\t}\n\treturn code, nil\n}\n\n// pkgPath determines the package import path of the current working directory,\n// and indicates whether it is\n// and returns the path to the package source relative to $GOROOT (or $GOPATH).\nfunc pkgPath() (importPath string, isStd bool, modPath, modDir string, err error) {","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/misc/go_android_exec/main.go#L258-L294","documentation":"Returned by exitCodeFilter.Finish (main.go:276) when the buffered adb output did not contain a full match of the exit-code regex (the captured group was absent). go_android_exec parses the test binary's exit code out of adb stdout via a regex; if the process produced no recognizable 'exit status N' marker, the wrapper cannot determine the result.","triggerScenarios":"The wrapped binary crashed before printing the exit marker, was killed (SIGKILL/OOM), or the device/adb truncated output so the marker line never arrived. Also if a custom binary does not emit the expected exit-code line format.","commonSituations":"Test binary crashed early (nil-pointer, native panic) and printed no exit marker; device ran out of memory and killed the process; adb exec-out stream was interrupted; running a non-Go-test binary through go_android_exec.","solutions":["Inspect the flushed output quoted in the error message — it is the raw trailing stdout from the device and usually contains the crash reason.","Run the binary directly via `adb exec-out` to reproduce and capture full output.","Check logcat (`adb logcat`) for native crashes / OOM kills of the test process.","Ensure the binary actually reaches normal exit; if it is killed, fix the underlying crash."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"code, err := run.onDevice(...)\nif err != nil {\n    // err.Error() contains the raw flushed stdout — inspect it for crash cause.\n    log.Printf(\"device run failed, tail output: %v\", err)\n    return err\n}","preventionTips":["Capture and log the quoted buffer embedded in the error — it holds the crash reason.","Run the binary directly via adb exec-out to reproduce.","Watch logcat for native/OOM kills of the test process."],"tags":["android","adb","go-test","exit-code","diagnostics"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}