0

I am attempting to write a Go function that sends a string to a C function as a C.CString.

func AssertString(fact string) {
    // sbytes := []byte(fact)
    // ccp := (*C.char)(unsafe.Pointer(&sbytes[0]))
    ccp := C.CString(fact)

    C.EnvAssertString(C.env, ccp)
}

I tried both the commented out section and the currently used section and I get the following

fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x30 pc=0x7431a9]

The C function EnvAssertString comes from the CLIPS Expert System library and looks like this:

globle void *EnvAssertString(void *theEnv, const char *theString)
  {
   struct fact *theFact;
   int danglingConstructs;
   danglingConstructs = ConstructData(theEnv)->DanglingConstructs;

   if ((theFact = StringToFact(theEnv,theString)) == NULL) return(NULL);

   if ((! CommandLineData(theEnv)->EvaluatingTopLevelCommand) &&
       (EvaluationData(theEnv)->CurrentExpression == NULL))
     { ConstructData(theEnv)->DanglingConstructs = danglingConstructs; }

   return((void *) EnvAssert(theEnv,(void *) theFact));
  }

I am assuming it is how the Go generated char pointer is used but I'm not exactly sure. Anyone got some ideas?

wmaxlees
  • 605
  • 1
  • 5
  • 21
  • Is `EnvAssert` a wrapper around `assert`? If so, maybe an assertion is failing and generating a signal? – joshlf Mar 26 '16 at 01:43
  • EnvAssert is a CLIPS function too. It asserts a fact in the rule based system. It's not related to unit testing asserts or anything like that. – wmaxlees Mar 26 '16 at 01:46

0 Answers0