Repository navigation
Closing one engine no longer breaks another in the same process (#791) (4.2.35) - #792
Merged
Merged
Conversation
… (4.2.35) Analyzer loading interns rule and function names into Htab::gstab_, the process-wide default string table. Each VTRun set it only when made, so with two NLP_ENGINEs open the one made last owned every analyzer's names; closing it freed them, and the other engine's next analyze() crashed or returned nothing. Found through NLPPlus, where set_working_folder and the test suite open several engines; AddressSanitizer showed the reads. Every NLP_ENGINE entry point (init, analyze, analyzeStream) now makes its own runtime's table the default first (VTRun::useStab), and a runtime being deleted clears the default if it pointed at its table. test-nlp gains a two-engine check, run in Windows CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Windows job checks out VisualText/analyzers near its end; before that, analyzers/parse-en-us has no spec and test-nlp could not build it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #791.
Cause. Analyzer loading interns rule and function names (rule-element hash tables, rule tables, user-function tables) into
Htab::gstab_, the process-wide default string table. EachVTRunsetgstab_only once, when it was created. So with twoNLP_ENGINEs open, the one created last owned every analyzer's names, including those of analyzers the first engine loaded afterwards. Closing it freed them, and the first engine's nextanalyze()read freed memory: it crashed or returned nothing. AddressSanitizer (MSVC/fsanitize=address) reported the bad read inStab::currSize←Ifunc::loadHtab←NLP::make_analyzer.It shows up in NLPPlus:
set_working_folder()and the test suite open several engines. VisualText/py-package-nlpengine#46 worked around it on the Python side.Fix.
VTRun::useStab()makes a runtime's own table the default.NLP_ENGINEentry point (init, the threeanalyzeoverloads,analyzeStream) calls it first.VTRun::clear()resets the default to null if it pointed at the table being freed, so nothing is left dangling.Regression test.
test-nlp(test/main.cpp) gets a two-engine check. It opens an engine, opens a second, has the first load an analyzer while the second is the newest, closes the second, then analyzes with the first. It fails on master ("engine broken after closing another, cycle 0") and passes with the fix. The new Windows CI step builds and runstest-nlp, which CI never ran before.Tests:
$GITHUB_WORKSPACEand always fails locally.After this releases, NLPPlus's one-engine-at-a-time workaround stays harmless, and Python users can safely hold several
Engines.🤖 Generated with Claude Code