duannao1920 2016-03-26 01:39
浏览 155

CGo:运行时意外信号

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 Unity接入微信SDK 无法开启摄像头
    • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算
    • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
    • ¥20 有人知道这种图怎么画吗?
    • ¥15 pyqt6如何引用qrc文件加载里面的的资源