When executing the following code, in most of the cases a segfault follows. In some cases, a wrong value is set for the slot.
#include "clips.h"
int main()
{
Environment *environment;
Instance *instance;
InstanceModifier *modifier;
environment = CreateEnvironment();
Build(environment,
"(defclass MYCLASS (is-a USER)"
" (slot One))");
Build(environment,
"(defclass MYSUBCLASS (is-a MYCLASS)"
" (slot Two))");
instance = MakeInstance(environment, "(p1 of MYSUBCLASS (One 1) (Two 2))");
modifier = CreateInstanceModifier(environment, instance);
IMPutSlotInteger(modifier, "One", 1);
IMPutSlotInteger(modifier, "Two", 2); // Segfault here
IMModify(modifier);
IMDispose(modifier);
DestroyEnvironment(environment);
}
The segfault occurs when calling Release on oldValue. oldValue->header appears to be NULL. I suspect the issue being caused by FindInstanceTemplateSlot returning the wrong slot id (stored in whichSlot) in case of a subclass.
Checked in a fix to the 64x branch of the sourceforge code repository.