Closed IanEmmons closed 5 years ago
Tracked this issue down to a runaway mutual recursion in the rule engine and created a C++ unit test (InferenceStressTest) that reproduces the issue. Here's the recipe:
The order here is important. Upon finding that C is a subclass of B, the rule engine asserts that each of the instances of C is also of types B and A. But rather than do this in a simple loop, it does it through a complex mutual recursion. (It's mutual in the sense that rather than a single function that calls itself, there is a lengthy chain of functions where f1 calls f2, which calls f3, which calls ..., which calls fN, which calls f1.)
The fix is to arrange that the kbInstance::addStmt method detects recursive calls to itself and in such cases does not actually add a new statement (thereby triggering the rule engine), but instead simply adds the new statement to a stack. Then before exiting, the method pops a statement off the stack (if one is present) and adds it until the stack is empty.
This fix required an extra trickiness. If addStmt is called with a statement that is part of a reification, then this will also cause a pair of recursive calls to addStmt, but these calls must not be deferred, because the outer call needs the statement IDs of the statements added in the recursive calls. A bit of careful refactoring fixed this issue.
Fixed by PR #20, "Deft sample data crash".
When importing the DEFT sample data load, Parliament crashes. Specifically, If we create a JenaGraph and import the sample data, the JVM exits abruptly without producing a JVM core dump. This crash does not happen when importing the same data into an in-memory Jena model, or into a native Parliament graph.