sleyzerzon / soar

Automatically exported from code.google.com/p/soar
1 stars 0 forks source link

Null Pointer Crash on Invalid Soar Code #146

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The following brief Soar code will crash Soar with a Null Pointer Exception.

...
    (<s> ^smem.command.store <store>)
-->
    (<s> ^smem.command.store <store> -)
...

This is invalid soar code in that it won't do what you might think it should, 
remove the store WM on the smem.command link.  Instead since this is on the RHS 
and is dot notation, it will expand <s> ^smem.command.store to:

sp {apply*successful-store
    (state <s> ^storage <storage> ^smem <s*1>)
    (<s*1> ^command <c*1>)
    (<c*1> ^store <store>)
    -->
    (<s> ^smem <s*2> +)
    (<s*2> ^command <c*2> +)
    (<c*2> ^store <store> -)
}

And so it will fail in prefmem.cpp:remove_preference_from_tm:373 because slot* 
s is NULL and it tries to access the element all_preferences on the slot 
pointer.  Ideally this should fail more gracefully than crashing Soar but 
unfortunately it does.

Attached is Soar code which consistently exposes this issue.  Just launch the 
Soar Java Debugger and source the file and try to run for an infinite number of 
decisions.  It will crash on the third decision cycle because of this issue.

Original issue reported on code.google.com by alex.tur...@soartech.com on 5 Aug 2013 at 3:03

Attachments: