{"record":{"id":"d15e6f8d4002d301","repo":"slimtoolkit/slim","slug":"ptmon-target-app-startup-failed-q","errorCode":null,"errorMessage":"ptmon: target app startup failed: %q","messagePattern":"ptmon: target app startup failed: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/monitor/ptrace/monitor.go","lineNumber":120,"sourceCode":"\t\tm.includeNew,\n\t\tm.origPaths,\n\t\tm.signalCh,\n\t\tm.errorCh,\n\t)\n\tif err != nil {\n\t\treturn errors.SE(\"sensor.ptrace.Run/ptrace.Run\", \"call.error\", err)\n\t}\n\tm.app = app\n\n\tappState := <-app.StateCh\n\tlogger.\n\t\tWithField(\"state\", appState).\n\t\tDebugf(\"pta state watcher - new target app state\")\n\n\tif appState == ptrace.AppFailed {\n\t\t// Don't need to wait for the 'done' state.\n\t\tlogger.Error(\"pta state watcher - target app failed\")\n\t\treturn fmt.Errorf(\"ptmon: target app startup failed: %q\", appState)\n\t}\n\tif appState != ptrace.AppStarted {\n\t\t// Cannot really happen.\n\t\tlogger.Error(\"pta state watcher - unexpected target app state\")\n\t\treturn fmt.Errorf(\"ptmon: unexpected target app state %q\", appState)\n\t}\n\n\t// The sync part of the start was successful.\n\n\t// Tracking the completetion of the monitor.\n\tgo func() {\n\t\tlogger := m.logger.WithField(\"op\", \"sensor.pt.monitor.completetion.monitor\")\n\t\tlogger.Info(\"call\")\n\t\tdefer logger.Info(\"exit\")\n\n\t\tappState := <-app.StateCh\n\t\tif appState == ptrace.AppDone {\n\t\t\tm.status.report = <-app.ReportCh","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/monitor/ptrace/monitor.go#L102-L138","documentation":"The ptrace monitor watches the target app's state channel during Start(). If the app transitions to ptrace.AppFailed, Start() aborts with this error instead of waiting for the done state. It indicates the traced application failed to start under ptrace supervision.","triggerScenarios":"Calling Start() and receiving ptrace.AppFailed on app.StateCh — the traced binary failed to exec, crashed during startup, or ptrace attach was denied.","commonSituations":"Target binary missing or lacking execute permission; missing dynamic loader/libraries inside the container; seccomp/AppArmor blocking ptrace; running without CAP_SYS_PTRACE (e.g. non-root in Docker without --cap-add=SYS_PTRACE).","solutions":["Read the quoted state in the message and check the app's own stderr (captured in app stdout/stderr logs) for the root failure.","Run the sensor with sufficient privileges: root or docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined.","Verify the target binary exists, is executable, and its dependencies (dynamic linker, shared libs) are present.","If targeting a newer kernel with Yama, set ptrace_scope appropriately or run as root."],"exampleFix":"// before (docker)\ndocker run myimage sensor myapp\n// after (docker)\ndocker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined myimage sensor myapp","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(targetBinary); err != nil {\n    return fmt.Errorf(\"target binary missing: %w\", err)\n}\nif m, _ := os.Stat(targetBinary); m.Perm()&0o111 == 0 {\n    return fmt.Errorf(\"target binary not executable\")\n}\nif os.Geteuid() != 0 {\n    log.Warn(\"ptrace typically requires root or CAP_SYS_PTRACE\")\n}","typeGuard":null,"tryCatchPattern":"if err := ptMon.Start(ctx); err != nil {\n    if strings.Contains(err.Error(), \"target app startup failed\") {\n        log.Errorf(\"target failed under ptrace; check app stderr logs and ptrace privileges: %v\", err)\n        return err\n    }\n    return err\n}","preventionTips":["Run the sensor as root or with CAP_SYS_PTRACE (docker run --cap-add=SYS_PTRACE).","Verify the target binary and its runtime dependencies exist inside the environment.","Relax seccomp/AppArmor profiles that deny ptrace for the sensor container."],"tags":["ptrace","process","startup"],"backgroundTag":"ptrace-attach-failed","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}