segfault使用SWIG转换代码为tcl [英] segfault using SWIG converted code for tcl

查看:547
本文介绍了segfault使用SWIG转换代码为tcl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程式发生区隔错误。



事实上,我使用C ++写了一个库,并使用SWIG将其转换为tcl。



  return Tcl_NewIntObj(static_cast< int>(value)); 

where value = 0



返回跟踪显示:

 (gdb)bt 
#0 0x000054b6 in? (value = 0)at mntdisplay_wrap.cc:1722
#3 Testguimnt_Init(interp = 0)在SWIG_From_long(值= 0)中的
#1 0xb6650d5d在mntdisplay_wrap.cc:1712
# 0xb75d02af在/ opt / ActiveTcl中的TclNREvalObjv()中,来自/opt/ActiveTcl-8.6/lib/libtcl8.6.so
#5中的0xb75d02af(5)0xb75d02af(0,0x9714e28)at mntdisplay_wrap.cc:3774
#4 0xb76748fe -8.6 / lib / libtcl8.6.so
#6 0xb75d0859在Tcl_EvalObjv()从/opt/ActiveTcl-8.6/lib/libtcl8.6.so
#7 0xb75d0d99在TclEvalEx()从/ opt /ActiveTcl-8.6/lib/libtcl8.6.so
#8 0xb7670045在Tcl_FSEvalFileEx()从/opt/ActiveTcl-8.6/lib/libtcl8.6.so
#9 0xb767645f在Tcl_MainEx()从/opt/ActiveTcl-8.6/lib/libtcl8.6.so
#10 0x0804885c in main()


$ b b

在包装器中:
line 1712:

  SWIGINTERNINLINE Tcl_Obj * 
SWIG_From_long )
{
if(((long)INT_MIN <= value)&&(value< =(long)INT_MAX)){
return Tcl_NewIntObj(static_cast< int>(value)); // 1712
} else {
return Tcl_NewLongObj(value);
}
}

1722:

  SWIGINTERNINLINE Tcl_Obj * 
SWIG_From_int(int value)
{
return SWIG_From_long // 1722
}

3774:


$ b b

  SWIG_Tcl_SetConstantObj(interp,MESSAGE_NEW,SWIG_From_int(static_cast< int>(MESSAGE_NEW))) 

其中MESSAGE_NEW在枚举中定义且为0。



请,如果你有任何想法,请帮助我。谢谢!



编辑:



我找到了问题的原因: p>

我为此问题创建了一个新主题:



C ++:链接库消失并在执行期间给出segfault



请参阅我的其他帖子:
解决方案

/stackoverflow.com/questions/18379452/c-linked-library-disappears-and-gives-segfault-during-execution/18380228#18380228\">C++:链接库在执行期间消失并提供segfault



我的图书馆有一个未定义的符号。我定义它和问题解决!



混乱是,我的程序崩溃在tcl包装函数中间(其中我的未定义的符号没有涉及)。我真的不知道为什么,但这是它。



希望它会帮助别人!


I'm having a segmentation fault with my program.

In fact I write a library in C++ and convert it for tcl using SWIG.

The segfault occurs here:

return Tcl_NewIntObj(static_cast< int >(value));

where value=0

the gdb back trace shows:

(gdb) bt
#0  0x000054b6 in ?? ()
#1  0xb6650d5d in SWIG_From_long (value=0) at mntdisplay_wrap.cc:1712
#2  SWIG_From_int (value=0) at mntdisplay_wrap.cc:1722
#3  Testguimnt_Init (interp=0x9714e28) at mntdisplay_wrap.cc:3774
#4  0xb76748fe in Tcl_LoadObjCmd () from /opt/ActiveTcl-8.6/lib/libtcl8.6.so
#5  0xb75d02af in TclNREvalObjv () from /opt/ActiveTcl-8.6/lib/libtcl8.6.so
#6  0xb75d0859 in Tcl_EvalObjv () from /opt/ActiveTcl-8.6/lib/libtcl8.6.so
#7  0xb75d0d99 in TclEvalEx () from /opt/ActiveTcl-8.6/lib/libtcl8.6.so
#8  0xb7670045 in Tcl_FSEvalFileEx () from /opt/ActiveTcl-8.6/lib/libtcl8.6.so
#9  0xb767645f in Tcl_MainEx () from /opt/ActiveTcl-8.6/lib/libtcl8.6.so
#10 0x0804885c in main ()

In the wrapper: line 1712:

SWIGINTERNINLINE Tcl_Obj* 
SWIG_From_long  (long value)
{
  if (((long) INT_MIN <= value) && (value <= (long) INT_MAX)) {
    return Tcl_NewIntObj(static_cast< int >(value));  //1712
  } else {
    return Tcl_NewLongObj(value);
  }
}

1722:

SWIGINTERNINLINE Tcl_Obj *
SWIG_From_int  (int value)
{    
  return SWIG_From_long  (value); //1722
}

3774:

SWIG_Tcl_SetConstantObj(interp, "MESSAGE_NEW", SWIG_From_int(static_cast< int >(MESSAGE_NEW)));

where MESSAGE_NEW is defined in a enum and is 0.

Please, if you have any idea, please help me. Thank you!

EDIT:

I found the cause of the problem: it's an linking error.

I created a new thread for this issue:

C++: linked library disappears and gives segfault during execution

解决方案

I found the problem.

Please see my other post: C++: linked library disappears and gives segfault during execution

There was an undefined symbol of my library. I defined it and problem solved!

The confusion was, my program crashed in the middle of tcl wrapper functions (where my undefined symbol was not involved at all). I don't really know why but that's it..

Hope it will help others!

这篇关于segfault使用SWIG转换代码为tcl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆