{"record":{"id":"e7c0a1e8f62890ce","repo":"NationalSecurityAgency/ghidra","slug":"there-is-no-thread","errorCode":null,"errorMessage":"There is no thread","messagePattern":"There is no thread","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java","lineNumber":274,"sourceCode":"\t */\n\tdefault TraceThread requireCurrentThread() {\n\t\tTraceThread thread = getCurrentThread();\n\t\tif (thread == null) {\n\t\t\tthrow new IllegalStateException(\"There is no current thread\");\n\t\t}\n\t\treturn thread;\n\t}\n\n\t/**\n\t * Require that the given thread is not null\n\t * \n\t * @param thread the thread\n\t * @return the thread\n\t * @throws IllegalStateException if the thread is null\n\t */\n\tdefault TraceThread requireThread(TraceThread thread) {\n\t\tif (thread == null) {\n\t\t\tthrow new IllegalStateException(\"There is no thread\");\n\t\t}\n\t\treturn thread;\n\t}\n\n\t/**\n\t * Get the current trace program view\n\t * \n\t * <p>\n\t * The view is an adapter for traces that allows them to be used as a {@link Program}. However,\n\t * it only works for a chosen snapshot. Typically, {@link TraceProgramView#getSnap()} for this\n\t * view will give the same result as {@link #getCurrentSnap()}. The exception is when the UI is\n\t * displaying emulated (scratch) machine state. In that case, {@link #getCurrentSnap()} will\n\t * give the \"source\" snapshot of the emulated state, and {@link TraceProgramView#getSnap()} will\n\t * give the \"destination\" scratch snapshot. See {@link #getCurrentEmulationSchedule()}.\n\t * \n\t * @see #getCurrentDebuggerCoordinates()\n\t * @return the view\n\t */","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java#L256-L292","documentation":"Thrown by FlatDebuggerAPI.requireThread(thread) when the caller passes a null thread reference. This is a null-check guard for an explicitly supplied thread argument.","triggerScenarios":"Calling requireThread(someThread) where someThread is null, e.g., a thread obtained from a lookup by index that did not exist.","commonSituations":"Looking up a thread by index/id that is out of range; passing a thread reference from a stale trace; chaining lookups with a null intermediate result.","solutions":["Check the thread variable for null before calling requireThread().","Validate the lookup index/id against the trace's thread list before indexing.","Use getCurrentThread() if you meant the active thread."],"exampleFix":"// before\nTraceThread th = trace.getThreadManager().getThread(idx); // may be null\nrequireThread(th); // throws\n\n// after\nTraceThread th = trace.getThreadManager().getThread(idx);\nif (th == null) {\n    println(\"No thread at index \" + idx);\n    return;\n}","handlingStrategy":"validation","validationCode":"if (thread == null) {\n    println(\"Thread reference is null\");\n    return;\n}","typeGuard":"static boolean isNonNullThread(TraceThread t) {\n    return t != null;\n}","tryCatchPattern":"try {\n    requireThread(thread);\n} catch (IllegalStateException e) {\n    if (e.getMessage().equals(\"There is no thread\")) {\n        thread = getCurrentThread();\n    } else throw e;\n}","preventionTips":["Validate thread lookup results against the thread manager's list.","Null-check thread variables after index/id lookups."],"tags":["flat-debugger-api","thread","null-check","debugger"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}