Skip to content

Fix segfault when using ALL() for rel comparison#609

Merged
adsharma merged 2 commits into
LadybugDB:mainfrom
mdbenito:fix/all-in-recursive-rel
Jun 22, 2026
Merged

Fix segfault when using ALL() for rel comparison#609
adsharma merged 2 commits into
LadybugDB:mainfrom
mdbenito:fix/all-in-recursive-rel

Conversation

@mdbenito

Copy link
Copy Markdown
Contributor

This is a followup to #608 , completing the porting of the fixes in predictable-labs/ryugraph#2.

Instead of the custom data in the original PR I used the tinysnb dataset.

I also added another change from that PR, defensively avoiding an assert in debug builds in NodeOrRelExpression::addPropertyExpression

@adsharma

Copy link
Copy Markdown
Contributor
[2026-06-22 14:55:30.271] [info] DEBUG LOG: RecursivePathWithAllAndRelComparison
[2026-06-22 14:55:30.271] [info] QUERY: MATCH (a:person)-[t:knows]->(d:person) WHERE a.ID <> d.ID WITH a, d, t MATCH p = (a)-[:knows*1..3]->(d) WHERE length(p) >= 2 AND ALL (r IN relationships(p) WHERE r <> t) WITH DISTINCT t RETURN count(t);
/home/runner/work/ladybug/ladybug/test/test_runner/test_runner.cpp:200: Failure
Value of: queryResult->isSuccess()
  Actual: false
Expected: true
Unexpected error for query: Assertion failed in file "/home/runner/work/ladybug/ladybug/src/include/common/cast.h" on line 30: false

@mdbenito mdbenito force-pushed the fix/all-in-recursive-rel branch from 8d7ae06 to 556dec8 Compare June 22, 2026 18:55
@mdbenito

Copy link
Copy Markdown
Contributor Author

Yes, sorry, I thought I had rebased on the correct branch. Part of the fix was on my previous PR, so this one could not pass the test. Now it should be ok.

@adsharma

Copy link
Copy Markdown
Contributor

Something like:

https://gist.github.com/adsharma/9c189d8bec7df072cd3cae3ba30acd6d

has the same effect but less repeated code.

@mdbenito

Copy link
Copy Markdown
Contributor Author

Actually there is no repetition, it's github being confused by the rebasing. This PR adds two lines. Let me rebase again on main

@adsharma

Copy link
Copy Markdown
Contributor

Yes, the duplicate code already went into main #608, but could be optimized via the change above, since the fall through code passes tests even after eliminating the

if (child->expressionType == ExpressionType::PATTERN)

check inside the loop.

@mdbenito mdbenito force-pushed the fix/all-in-recursive-rel branch from 556dec8 to 07e7e64 Compare June 22, 2026 19:15
@mdbenito mdbenito force-pushed the fix/all-in-recursive-rel branch from 07e7e64 to 67d74d7 Compare June 22, 2026 20:04
@mdbenito

Copy link
Copy Markdown
Contributor Author

Ahh, I see what you mean. Just check if it's a pattern outside so we don't repeat what comes after the loop. Done!

@adsharma adsharma merged commit 7eab431 into LadybugDB:main Jun 22, 2026
4 checks passed
@mdbenito mdbenito deleted the fix/all-in-recursive-rel branch June 23, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants