我在Hp-ux上使用swig 2.0.7来包装我们的C ++库。在发生崩溃时尝试运行之前没有错误。
使用:
HP-UX bob B.11.23 U ia64 0835920252 unlimited-user license
aCC: HP C/aC++ B3910B A.06.20 [May 13 2008]
java version "1.7.0.01"
Java(TM) SE Runtime Environment (build 1.7.0.01-jinteg_2012_05_10_04_39-b00)
Java HotSpot(TM) Server VM (build 22.1-b02-jre1.7.0.01-rc2, mixed mode)
swig命令是
swig -c++ -package com.mybuild -java -I../Library -I../../Common mybuild.i
swig接口文件
/* File : mybuild.i */
%module mybuild
%include "std_string.i"
%{
#include "mybuild.h"
%}
%include "mybuild.h"
在建设时,我看到一个警告
warning #2177-D: function
"SWIG_JavaThrowException" was declared but never referenced
static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) {
当我跑步时发生故障,发生崩溃并且我得到了
(0) 0xc0000000054f4f60 _ZN6Thread18trace_native_stackEv + 0x140 [/opt/java7/jre/lib/IA64W/server/libjvm.so]
(1) 0xc0000000055b10c0 _ZN7VMError14report_and_dieEv + 0x6c0 [/opt/java7/jre/lib/IA64W/server/libjvm.so]
(2) 0xc0000000050d85b0 _Z30_handle_uncaught_cxx_exceptionv + 0x50 [/opt/java7/jre/lib/IA64W/server/libjvm.so]
(3) 0xc0000000017390f0 _ZSt9terminatev + 0x50 [/usr/lib/hpux64/libCsup.so.1]
(4) 0xc000000001740090 __cxa_throw + 0x1b0 [/usr/lib/hpux64/libCsup.so.1]
(5) 0xc0000000015e3220 _ZNSs9_C_unlinkEv + 0x220 [/usr/lib/hpux64/libstd_v2.so.1]
(6) 0xc0000000015f08f0 _ZNSt5ctypeIcE12_C_initfacetERKSt6locale + 0x800 [/usr/lib/hpux64/libstd_v2.so.1]
(7) 0xc0000000015f3990 _ZNKSt6locale16_C_install_facetEPN4__rw15__rw_facet_baseERKNS_2idE + 0x1d0 [/usr/lib/hpux64/libstd_v2.so.1]
(8) 0xc0000000015f2ae0 _ZNKSt6locale13_C_make_facetERKNS_2idEbiPFPN4__rw15__rw_facet_baseEiPKcmE + 0x440 [/usr/lib/hpux64/libstd_v2.so.1]
(9) 0xc0000000016d5b60 _ZNSt8ios_base4InitC3Ev + 0x1c80 [/usr/lib/hpux64/libstd_v2.so.1]
(10) 0xc000000005e72f00 __sinit_optionset_cpp_ + 0x70 [/usr/testing/mybuild.so]
(11) 0xc00000000004e1a0 EM_mark_BOS + 0x50 [/usr/lib/hpux64/dld.so]
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (0xe0000000), pid=7231, tid=1
# Error: An uncaught C++ exception
#
# JRE version: 7.0
# Java VM: Java HotSpot(TM) 64-Bit Server VM (22.1-b02-jre1.7.0.01-rc2 mixed mode hp-ux-ia64 )
# Core dump written. Default location: /usr/testing/core or core.7231 (max size 2097151 kB). To ensure a full core dump, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /usr/testing/hs_err_pid7231.log
#
# Please report this error to HP customer support.
使用gdb,我收到了更多信息:
from /usr/lib/hpux64/libCsup.so.1
#16 0xc000000001740090:0 in __cxa_throw+0x1b0 ()
from /usr/lib/hpux64/libCsup.so.1
#17 0xc0000000015e3220:0 in std::string::_C_unlink()+0x220 ()
from /usr/lib/hpux64/libstd_v2.so.1
#18 0xc0000000015f08f0:0 in std::ctype<char>::_C_initfacet(std::locale const&)
+0x800 () from /usr/lib/hpux64/libstd_v2.so.1
#19 0xc0000000015f3990:0 in std::locale::_C_install_facet(__rw::__rw_facet_base*,std::locale::id const&) const+0x1d0 () from /usr/lib/hpux64/libstd_v2.so.1
#20 0xc0000000015f2ae0:0 in std::locale::_C_make_facet(std::locale::id const&,bool,int,__rw::__rw_facet_base* (*)(int,char const*,unsigned long)) const
---Type <return> to continue, or q <return> to quit---
+0x440 () from /usr/lib/hpux64/libstd_v2.so.1
#21 0xc0000000016d5b60:0 in std::ios_base::Init::Init()+0x1e40 ()
from /usr/lib/hpux64/libstd_v2.so.1
#22 0xc000000005e72f00:0 in __sinit_optionset_cpp_ ()
at /opt/aCC/include_std/iostream:48
#23 0xc00000000004e1a0:0 in EM_mark_BOS+0x50 () from /usr/lib/hpux64/dld.so
我的理论是,我需要调整Swig来阻止这次崩溃。将不胜感激。
修改了代码 对不起,我花了一些时间来讨论可能导致问题的原因。我发现这会导致崩溃
#include <iostream>
#include <string>
using namespace std;
static const string rangeFieldString("RangeField");
int main()
{
cout << "I sure hope this works" << endl;
return 0;
}
但这不会
#include <iostream>
#include <string>
using namespace std;
static const char* rangeFieldString("RangeField");
int main()
{
cout << "I sure hope this works" << endl;
return 0;
}
答案 0 :(得分:0)
我找到了解决方法。在系统上构建时,通过将-mt添加到CFLAGS和LDFLAGS,问题就解决了
CFLAGS=-Aa +e +DAportable +z +DD64 -mt
LDFLAGS=-Aa +e +DAportable -b +z +DD64 -mt