Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple PresentLink in a DefinedPredicate causes segfault #852

Closed
amebel opened this issue Aug 4, 2016 · 6 comments
Closed

Multiple PresentLink in a DefinedPredicate causes segfault #852

amebel opened this issue Aug 4, 2016 · 6 comments
Assignees

Comments

@amebel
Copy link
Contributor

amebel commented Aug 4, 2016

1. Steps to reproduce the error

scheme@(guile-user)> (use-modules (opencog) (opencog exec))
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /usr/local/share/opencog/scm/opencog.scm
;;; opencog.scm:45:30: warning: possibly unbound variable `cog-atomspace'
....
....
scheme@(guile-user)> (DefineLink
...     (DefinedPredicateNode "just for testing")
...     (SatisfactionLink
...         (AndLink
...             ; If someone is visible...
...             (PresentLink (EvaluationLink (PredicateNode "visible face")
...                     (ListLink (VariableNode "$face-id-nn"))))
...             ; but not yet acknowledged...
...             (AbsentLink (EvaluationLink (PredicateNode "acked face")
...                     (ListLink (VariableNode "$face-id-nn"))))
...             ; and is recognizable
...             (PresentLink (EvaluationLink (PredicateNode "name")
...                     (ListLink
...                     (VariableNode "$face-id")
...                     (VariableNode "$recog-id"))))
...             (Not (Equal (VariableNode "$recog-id") (ConceptNode "0")))
...             )))
$1 = (DefineLink
   (DefinedPredicateNode "just for testing")
   (SatisfactionLink
      (AndLink
         (PresentLink
            (EvaluationLink
               (PredicateNode "visible face")
               (ListLink
                  (VariableNode "$face-id-nn")
               )
            )
         )
         (AbsentLink
            (EvaluationLink
               (PredicateNode "acked face")
               (ListLink
                  (VariableNode "$face-id-nn")
               )
            )
         )
         (PresentLink
            (EvaluationLink
               (PredicateNode "name")
               (ListLink
                  (VariableNode "$face-id")
                  (VariableNode "$recog-id")
               )
            )
         )
         (NotLink
            (EqualLink
               (VariableNode "$recog-id")
               (ConceptNode "0")
            )
         )
      )
   )
)

scheme@(guile-user)> (cog-evaluate! (DefinedPredicateNode "just for testing"))
Segmentation fault (core dumped)

2 Expected result

scheme@(guile-user)> (cog-evaluate! (DefinedPredicateNode "just for testing"))
$2 = (stv 0 1)
@linas
Copy link
Member

linas commented Aug 4, 2016

looking

@linas linas self-assigned this Aug 4, 2016
linas added a commit to linas/atomspace that referenced this issue Aug 4, 2016
Patterns with multiple components may fail to ground one of
the parts; this is normal and is handled up-stream.
linas added a commit that referenced this issue Aug 4, 2016
Fix multi-component pattern crash (bug #852)
@linas
Copy link
Member

linas commented Aug 4, 2016

pull req #853 fixes this.

Its not the multiple PresentLinks, its the EqualLink that cause the issue -- the pattern got split into multiple components. (although that too is a bug .. it should really be a single-component pattern. I'm looking into that now.

@linas
Copy link
Member

linas commented Aug 4, 2016

Ah! BTW, your example above has a bug in it -- the third variable should be (VariableNode "$face-id-nn") instead of (VariableNode "$face-id") This bug was triggering the multi-component path.

There is some code that actually checks for this syntax error, and would catch it and report it -- but it got disabled, because PLN intentionally constructs such invalid graphs, and still expects them to work right :-(

Also BTW, you can get a minor performance boost by using IdenticalLink instead of EqualLink. See http://wiki.opencog.org/wikihome/index.php/EqualLink

@amebel
Copy link
Contributor Author

amebel commented Aug 5, 2016

No, the third variable is (VariableNode "$face-id"). The DefinedPredicate is not complete, I kept the ugly part for a pr :-). To reproduce the bug the (Not (Equal.. wasn't needed.

What is an invalid graph? Do you mean a graph which doesn't make semantic sense?

Thanks on the fix and hint :-)

@linas
Copy link
Member

linas commented Aug 5, 2016

well, the graph has two disconnected parts. You're right, its not the EqualLink, I thought that was the reason it had two disconnected parts until I saw the mis-matched names. The bug triggered because it has two independent parts, one not linked to the other. Changedin the variable names links them back into one.

Anyway, it should all work now.

@linas
Copy link
Member

linas commented Aug 13, 2016

closing I believe this is fixed

@linas linas closed this as completed Aug 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants