{"record":{"id":"f11e78d9a24fc349","repo":"stanfordnlp/CoreNLP","slug":"outputhandler-received-endtrack-without-matching","errorCode":null,"errorMessage":"OutputHandler received endTrack() without matching startTrack() --are your handlers mis-configured?","messagePattern":"OutputHandler received endTrack\\(\\) without matching startTrack\\(\\) --are your handlers mis-configured\\?","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/logging/OutputHandler.java","lineNumber":430,"sourceCode":"    if(info != null){\n      this.trackStack.push(info);\n    }\n    info = new TrackInfo(signal.content.toString(), signal.timesstamp);\n    //(force print)\n    if(signal.force()){\n      updateTracks(signal.depth+1);\n    }\n    //(return)\n    return EMPTY; //don't send extra records\n  }\n\n  /** {@inheritDoc} */\n  @Override\n  public List<Record> signalEndTrack(int newDepth, long timeOfEnd) {\n    //(pop info)\n    TrackInfo childInfo = this.info;\n    if (childInfo == null) {\n      throw new IllegalStateException(\"OutputHandler received endTrack() without matching startTrack() --\" +\n          \"are your handlers mis-configured?\");\n    }\n    if(trackStack.empty()){\n      this.info = null;\n    } else {\n      this.info = this.trackStack.pop();\n      this.info.numElementsPrinted += childInfo.numElementsPrinted;\n    }\n    //(handle track)\n    if(this.queuedTracks.isEmpty()){\n      StringBuilder b = new StringBuilder();\n      if (!this.missingOpenBracket) {\n        //(write margin)\n        for(int i=0; i<this.leftMargin; i++) {\n          b.append(' ');\n        }\n        //(null content)\n        writeContent(newDepth, \"\", b);","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/logging/OutputHandler.java#L412-L448","documentation":"Redwood's OutputHandler.signalEndTrack throws IllegalStateException when endTrack() is called but this handler has no currently open TrackInfo, meaning endTrack arrived without a matching startTrack. This indicates logging handlers/channels were configured inconsistently (e.g. one handler received start but another received end).","triggerScenarios":"Calling Redwood.endTrack(title) when no startTrack(title) is active; custom LogRecordHandler pipelines where startTrack was routed to a different handler than endTrack; reusing/clearing handlers mid-track.","commonSituations":"Library code that opens a track on one code path but ends it on another (early return/exception before endTrack); swapping RedwoodConfiguration handlers between startTrack and endTrack; nested library calls each managing tracks incorrectly.","solutions":["Ensure every startTrack(title) has exactly one matching endTrack(title) on all control-flow paths (finally block)","Reconfigure handlers only when no track is open (Redwood.depth == 0)","Check for start/end calls issued to different handler sets after RedwoodConfiguration.apply(...)","Log Redwood.depth before endTrack calls during debugging to find the unbalanced one"],"exampleFix":"// before\nRedwood.startTrack(\"training\");\nrunEpoch(); // may throw -> endTrack skipped\nRedwood.endTrack(\"training\");\n// after\nRedwood.startTrack(\"training\");\ntry {\n  runEpoch();\n} finally {\n  Redwood.endTrack(\"training\");\n}","handlingStrategy":"try-catch","validationCode":"if (Redwood.depth == 0) throw new IllegalStateException(\"endTrack without startTrack\");\nRedwood.endTrack(title);","typeGuard":null,"tryCatchPattern":"try {\n  Redwood.endTrack(\"training\");\n} catch (IllegalStateException e) {\n  log.warn(\"Unbalanced endTrack: {}\", e.getMessage());\n  // inspect handler configuration and track depth\n}","preventionTips":["Pair every startTrack with endTrack in try/finally","Only reconfigure logging handlers when Redwood.depth == 0","Avoid mixing multiple handler-configuration styles (RedwoodConfiguration.apply vs manual addChild)","Check that all code paths (including exceptions) reaching endTrack had a matching startTrack"],"tags":["logging","redwood","unbalanced-calls","state"],"backgroundTag":"invalid-state-transition","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}