sleyzerzon / soar

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

Document why SML WMElement objects can go invalid and how to work around it #58

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The method sml::Agent::DestroyWME removes a WMElement from working memory.
Soar will also automatically remove all WMEs from working memory that
become disconnected from top state due to the removal of that one WME. If
DestroyWME is subsequently called on a WME that was removed in this
recursive process, SML will try to dereference invalid memory and segfault.

This is arguably not desirable behavior, since the user has no easy way of
knowing what recursive deletions occurred due to calls to DestroyWME and
therefore cannot avoid calling DestroyWME for WMEs that have already been
removed.

I have attached a test case that reproduces this problem with just two
identifiers.

Original issue reported on code.google.com by joseph...@gmail.com on 13 Nov 2009 at 9:18

GoogleCodeExporter commented 8 years ago
The WMElement objects returned by SML are not owned by the client, and various 
function calls by SML or various WME operations by the agent can cause these 
references to go invalid. When these references go invalid, if they are used at 
all it can 
cause a segmentation fault.

There is not an easy way to fix this without breaking backwards compatibility. 
Instead, 
we are going to document this in the FAQ and in the method documentation.

Original comment by voigtjr@gmail.com on 23 Feb 2010 at 8:22

GoogleCodeExporter commented 8 years ago

Original comment by voigtjr@gmail.com on 24 Feb 2010 at 9:41