Fix SPARQL parser backtrack, executor memory leak, and add catch_unwind#180
Open
grparry wants to merge 1 commit intoruvnet:mainfrom
Open
Fix SPARQL parser backtrack, executor memory leak, and add catch_unwind#180grparry wants to merge 1 commit intoruvnet:mainfrom
grparry wants to merge 1 commit intoruvnet:mainfrom
Conversation
Three additional hardening fixes for the SPARQL subsystem, building on PR ruvnet#172: 1. Parser: replace hardcoded saturating_sub(6) with saved_pos variable. The old backtrack assumed all update keywords are 6 chars, but LOAD, DROP, and CLEAR are 4-5 chars, causing incorrect parse positions. 2. Executor: change default_graph from Option<&'a str> to Option<String> and remove Box::leak calls in the GraphPattern::Graph handler. Each GRAPH clause previously leaked a String allocation that was never freed. 3. Operators: wrap ruvector_sparql parse/execute/format in catch_unwind so that panics from non-empty but malformed queries are converted to PostgreSQL ERROR messages instead of crashing the backend. Closes ruvnet#167 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 17, 2026
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.
Summary
Three additional hardening fixes for the SPARQL subsystem, building on PR #172:
Parser backtrack fix: Replace hardcoded
saturating_sub(6)with asaved_posvariable. The old backtrack assumed all update keywords are 6 characters, butLOAD(4),DROP(4), andCLEAR(5) are shorter, causing incorrect parse positions for those statements.Executor memory leak fix: Change
SparqlContext.default_graphfromOption<&'a str>toOption<String>and removeBox::leakcalls in theGraphPattern::Graphhandler. EachGRAPHclause previously leaked aStringallocation that was never freed.catch_unwind safety net: Wrap
ruvector_sparql()parse/execute/format instd::panic::catch_unwindso that panics from non-empty but malformed queries are converted to PostgreSQLERRORmessages instead of crashing the backend. This complements the empty-query check from fix: HNSW index bugs, agent/SPARQL crashes, lru security #172 by catching deeper failures.Closes #167
Test plan
LOAD,CLEAR,DROPSPARQL update statements parse correctly (parser backtrack)GRAPH <iri> { ... }queries don't leak memory (executor fix)🤖 Generated with Claude Code