opennars / Narjure

A Clojure implementation of the Non-Axiomatic Reasoning System proposed by Pei Wang.
GNU General Public License v2.0
43 stars 11 forks source link

narjure.bag.DefaultBag StackOverflowError #61

Closed jorisbontje closed 8 years ago

jorisbontje commented 8 years ago

Using a fresh started ircbot I get an StackOverflowError after the following 3 narsese lines:

<{tim} --> quacks>.
<duck --> quacks>.
<{tim} --> duck>?

This is with OpenNARS_2.0.0 / commit 5eac58faf8b51b5870369f57c563ddbb7a706836

Full stacktrace:

$ lein with-profile production trampoline run -m examples.ircbot
10:37:03.709 [main] INFO  c.p.actors.ActorRegistry - Actor registry is co.paralleluniverse.actors.LocalActorRegistry@7a6e0f3c
Beliefs rules: 3803
Questions rules: 474
Goal rules: 3813
Quests rules: 474
"Elapsed time: 59487.257198 msecs"
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:105] - reset question filter
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:107] - Resetting concepts bagss:
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:109] - c-bag count:  0
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:113] - Reset system Parameters:
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:115] - nars-id:  -1
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:117] - nars-time:  0
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:120] - NARS initialising...
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:56] - Initialising system timers...
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:51] -   [OK] :inference-timer (110 ms)
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:51] -   [OK] :system-timer (150 ms)
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:68] - System timer initialisation complete.
16-07-22 14:38:20 ubuntu-2gb-ams2-01 INFO [narjure.core:128] - NARS initialised.
Connecting... irc.freenode.org
Joining #narstest
NARS hears <{tim} --> quacks>.
NARS hears <duck --> quacks>.
NARS hears <{tim} --> duck>?
NARS answer on <{tim} --> duck>? is <{tim} --> duck>.  %1.0;0.44751381215469616%
Exception in Fiber "fiber-10000017" java.lang.StackOverflowError
        at clojure.lang.APersistentVector.equiv(APersistentVector.java:138)
        at clojure.lang.Util.pcequiv(Util.java:124)
        at clojure.lang.Util.equiv(Util.java:32)
        at clojure.core$not_EQ_.invokeStatic(core.clj:806)
        at clojure.core$not_EQ_.invoke(core.clj:800)
        at narjure.bag$compare_elements.invokeStatic(bag.clj:123)
        at narjure.bag$compare_elements.invoke(bag.clj:116)
        at clojure.lang.AFunction.compare(AFunction.java:47)
        at avl.clj$delete.invokeStatic(clj.clj:521)
        at avl.clj$delete.invoke(clj.clj:516)
        at avl.clj$delete.invokeStatic(clj.clj:554)
        at avl.clj$delete.invoke(clj.clj:516)
        at avl.clj$delete.invokeStatic(clj.clj:539)
        at avl.clj$delete.invoke(clj.clj:516)
        at avl.clj.AVLMap.without(clj.clj:885)
        at clojure.lang.RT.dissoc(RT.java:848)
        at clojure.core$dissoc.invokeStatic(core.clj:1462)
        at clojure.lang.RT.dissoc(RT.java:848)                                                                                          
        at clojure.core$dissoc.invokeStatic(core.clj:1462)
        at clojure.core$dissoc.invoke(core.clj:1455)
        at avl.clj.AVLSet.disjoin(clj.clj:1136)
        at clojure.core$disj.invokeStatic(core.clj:1477)
        at clojure.core$disj.invoke(core.clj:1469)
        at narjure.bag.DefaultBag.pop_element(bag.clj:89)
        at narjure.bag.DefaultBag.add_element(bag.clj:56)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
        at narjure.bag.DefaultBag.add_element(bag.clj:57)
... etc
patham9 commented 8 years ago

Nice catch, thanks a lot! :) Will have a look at it as soon as back in working mode.

jorisbontje commented 8 years ago

Update on this issue with 9099668fbbc6efdd8618872afb0324b9fcbdd933 (in patham9's PR repo)

mids@ubuntu-2gb-ams2-01:~/opennars2$ lein with-profile production trampoline run -m examples.ircbot
01:10:02.512 [main] INFO  c.p.actors.ActorRegistry - Actor registry is co.paralleluniverse.actors.LocalActorRegistry@72998021
Beliefs rules: 3803
Questions rules: 474
Goal rules: 3813
Quests rules: 474
"Elapsed time: 50743.501958 msecs"
16-07-28 05:11:08 ubuntu-2gb-ams2-01 INFO [narjure.core:105] - reset question filter
16-07-28 05:11:08 ubuntu-2gb-ams2-01 INFO [narjure.core:107] - Resetting concepts bagss:
16-07-28 05:11:08 ubuntu-2gb-ams2-01 INFO [narjure.core:109] - c-bag count:  0
16-07-28 05:11:08 ubuntu-2gb-ams2-01 INFO [narjure.core:113] - Reset system Parameters:
16-07-28 05:11:08 ubuntu-2gb-ams2-01 INFO [narjure.core:115] - nars-id:  -1
16-07-28 05:11:08 ubuntu-2gb-ams2-01 INFO [narjure.core:117] - nars-time:  0
16-07-28 05:11:08 ubuntu-2gb-ams2-01 INFO [narjure.core:120] - NARS initialising...
16-07-28 05:11:08 ubuntu-2gb-ams2-01 INFO [narjure.core:56] - Initialising system timers...
16-07-28 05:11:09 ubuntu-2gb-ams2-01 INFO [narjure.core:51] -   [OK] :inference-timer (20 ms)
16-07-28 05:11:09 ubuntu-2gb-ams2-01 INFO [narjure.core:51] -   [OK] :system-timer (25 ms)
16-07-28 05:11:09 ubuntu-2gb-ams2-01 INFO [narjure.core:68] - System timer initialisation complete.
16-07-28 05:11:09 ubuntu-2gb-ams2-01 INFO [narjure.core:128] - NARS initialised.
Connecting... irc.freenode.org
Joining #narstest
NARS hears <{tim} --> quacks>.
NARS hears <duck --> quacks>.
NARS hears <{tim} --> duck>?
NARS answer on <{tim} --> duck>? is <{tim} --> duck>.  %1.0;0.44751381215469616%
NARS answer on <{tim} --> duck>? is <{tim} --> duck>.  %1.0;0.40276243093922653%
question unification issue with question [--> [ext-set tim] [ext-image [* quacks quacks] _ [ext-set tim]]]
answer:[--> [ext-set tim] [ext-image [* quacks quacks] [ext-image [* quacks quacks] _ duck] _]]
java.lang.IllegalStateException: Cycle found in the path [ext-image [* quacks quacks] _ duck]
question unification issue with question [--> [ext-set tim] [ext-image [* quacks quacks] _ [ext-set tim]]]
answer:[--> [ext-set tim] [ext-image [* quacks quacks] [ext-image [* quacks quacks] _ duck] _]]
java.lang.IllegalStateException: Cycle found in the path [ext-image [* quacks quacks] _ duck]
question unification issue with question [--> [ext-set tim] [ext-image [* quacks quacks] _ [ext-set tim]]]
answer:[--> [ext-set tim] [ext-image [* quacks quacks] [ext-image [* quacks quacks] _ duck] _]]
java.lang.IllegalStateException: Cycle found in the path [ext-image [* quacks quacks] _ duck]
question unification issue with question [--> [ext-set tim] [ext-image [* quacks quacks] _ [ext-set tim]]]
answer:[--> [ext-set tim] [ext-image [* quacks quacks] [ext-image [* quacks quacks] _ duck] _]]
java.lang.IllegalStateException: Cycle found in the path [ext-image [* quacks quacks] _ duck]
question unification issue with question [--> [ext-set tim] [ext-image [* quacks quacks] _ [ext-set tim]]]
answer:[--> [ext-set tim] [ext-image [* quacks quacks] [ext-image [* quacks quacks] _ duck] _]]
java.lang.IllegalStateException: Cycle found in the path [ext-image [* quacks quacks] _ duck]
question unification issue with question [--> [ext-set tim] [ext-image [* quacks quacks] _ [ext-set tim]]]
answer:[--> [ext-set tim] [ext-image [* quacks quacks] [ext-image [* quacks quacks] _ duck] _]]
java.lang.IllegalStateException: Cycle found in the path [ext-image [* quacks quacks] _ duck]
question unification issue with question [--> [ext-set tim] [ext-image [* quacks quacks] _ [ext-set tim]]]
answer:[--> [ext-set tim] [ext-image [* quacks quacks] [ext-image [* quacks quacks] _ duck] _]]
java.lang.IllegalStateException: Cycle found in the path [ext-image [* quacks quacks] _ duck]
question unification issue with question [--> [ext-set tim] [ext-image [* quacks quacks] _ [ext-set tim]]]
answer:[--> [ext-set tim] [ext-image [* quacks quacks] [ext-image [* quacks quacks] _ duck] _]]
... etc ...
patham9 commented 8 years ago

These are cyclic unifications, we shouldn't print them out as they are just cases where the unifications can not succeed. The StackOverFlow still exists though, will look at it in the next days.

ryanpeach commented 8 years ago

I've been getting something similar running with the TCP implementation:

at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57)

Just kinda shows up randomly. That along with Stack Overflow Errors.

patham9 commented 8 years ago

Thats already fixed, my pull request will be ready this month (v2.0.1). On 13 Sep 2016 08:02, "Ryan Peach" notifications@github.com wrote:

I've been getting something similar running with the TCP implementation:

at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57) at narjure.bag.DefaultBag.add_element(bag.clj:57)

Just kinda shows up randomly. That along with Stack Overflow Errors.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/opennars/opennars2/issues/61#issuecomment-246583351, or mute the thread https://github.com/notifications/unsubscribe-auth/AH5qBT0VnJ8ZrWIFCuyodIBL4VmaY1jkks5qpjx3gaJpZM4JS0y1 .

patham9 commented 8 years ago

It seems that this indeed fixed it already. If not it will be reopenend.