0

我正试图围绕omniORB 准备使用它来与我们将获得的使用CORBA 的软件交互。我使用的策略是在omniORB(回声示例,特别是eg3_impl和eg3_cc)中举一个例子,并从接收到的软件中混合idl,直到它完成我想要的。为此,我试图将我正在编写的软件与omniORB 堆栈的其余部分隔离开来(即我正在尝试编写一个依赖于已编译库的独立makefile)。我正在使用从 sourceforge 下载的omniORB-4.2.3(通过omniORB-support.com 链接)。

我遇到的问题是,从独立 makefile 编译的示例似乎存在编译树示例没有的内存问题;

  1. 从独立 Makefile 编译的示例试图解除分配不是“malloc()”或“new”的指针。(烦人,但不是炫耀)
  2. 从独立 Makefile 编译的示例似乎没有正确记录字符串指针。(一个展示者)。

两个示例之间的源文件相同;唯一的区别是,非独立示例使用内置在omniORB树中的makefile结构,独立软件使用我编写的编译脚本,基于我在构建echo示例时观察到makefile结构所做的事情。

这是我的脚本:

WHICH_BUILD_DIR=build2
WHICH_VERSION=omniORB-4.2.3
INCLUDE_G_PLUS_PLUS="-I./idl_artifacts/ -I../${WHICH_VERSION}/include -I. -I../${WHICH_VERSION}/${WHICH_BUILD_DIR}/include"

DEFINES_G_PLUS_PLUS="-D__OMNIORB4__ -D_REENTRANT -D__OSVERSION__=2 -D__linux__ -D__x86__"

LIBRARY_G_PLUS_PLUS="-L../${WHICH_VERSION}/${WHICH_BUILD_DIR}/lib -L/usr/lib"
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/jasont/FACE_translator/omniORB-4.2.3/build2/lib

reset

if [ "~$1" == "~debug" ] ; then DEBUGGER_OPTION="-g"
else                            DEBUGGER_OPTION=""   ; fi
rm -rf ./idl_artifacts *.o eg3_impl eg3_clt eg3_tieimpl
mkdir idl_artifacts

#compile idl file to skeleton files
  ../${WHICH_VERSION}/${WHICH_BUILD_DIR}/bin/omniidl -bcxx -Wba -Wbtp -C./idl_artifacts/ echo.idl

#regular compile
  g++ -c $DEBUGGER_OPTION -O2 -Wall -Wno-unused -fexceptions $INCLUDE_G_PLUS_PLUS $DEFINES_G_PLUS_PLUS -o      echoSK.o  ./idl_artifacts/echoSK.cc
  g++ -c $DEBUGGER_OPTION -O2 -Wall -Wno-unused -fexceptions $INCLUDE_G_PLUS_PLUS $DEFINES_G_PLUS_PLUS -o    eg3_impl.o                eg3_impl.cc
# g++ -c $DEBUGGER_OPTION -O2 -Wall -Wno-unused -fexceptions $INCLUDE_G_PLUS_PLUS $DEFINES_G_PLUS_PLUS -o eg3_tieimpl.o             eg3_tieimpl.cc
  g++ -c $DEBUGGER_OPTION -O2 -Wall -Wno-unused -fexceptions $INCLUDE_G_PLUS_PLUS $DEFINES_G_PLUS_PLUS -o     eg3_clt.o                 eg3_clt.cc
  
#regular link
# g++ -o eg3_impl    -O2 -Wall -Wno-unused -fexceptions    eg3_impl.o echoSK.o $LIBRARY_G_PLUS_PLUS         -lomniORB4 -lomnithread -lpthread
##g++ -o eg3_tieimpl -O2 -Wall -Wno-unused -fexceptions eg3_tieimpl.o echoSK.o $LIBRARY_G_PLUS_PLUS         -lomniORB4 -lomnithread -lpthread
# g++ -o eg3_clt     -O2 -Wall -Wno-unused -fexceptions     eg3_clt.o echoSK.o $LIBRARY_G_PLUS_PLUS         -lomniORB4 -lomnithread -lpthread
  g++ -o eg3_impl    -O2 -Wall -Wno-unused -fexceptions    eg3_impl.o echoSK.o $LIBRARY_G_PLUS_PLUS -static -lomniORB4 -lomnithread -lpthread

./eg3_impl

...这就是我看到我的独立软件所做的事情(通过将 omniORB.cfg 跟踪级别设置为最大值来生成)

...
omniORB: (0) 2020-11-06 12:50:37.443054: LocateRequest to remote: key<NameService>
omniORB: (1) 2020-11-06 12:50:37.443022: giopRendezvouser task execute for giop:tcp:10.0.0.247:57082
omniORB: (2) 2020-11-06 12:50:37.443166: AsyncInvoker: thread id 2 has started. Total threads = 2.
omniORB: (2) 2020-11-06 12:50:37.443199: AsyncInvoker: thread id 2 assigned to general tasks. Total general threads = 2.
omniORB: (2) 2020-11-06 12:50:37.443217: AsyncInvoker: thread id 2 performing immediate general task.
omniORB: (2) 2020-11-06 12:50:37.443232: Scavenger task execute.
omniORB: (1) 2020-11-06 12:50:37.493125: SocketCollection idle. Sleeping.
omniORB: (0) 2020-11-06 12:50:38.443279: Client attempt to connect to giop:tcp:10.0.0.247:2809
omniORB: (0) 2020-11-06 12:50:38.443411: Client opened connection to giop:tcp:10.0.0.247:2809
omniORB: (0) 2020-11-06 12:50:38.443423: sendChunky: to giop:tcp:10.0.0.247:2809 35 bytes
omniORB: (0) 2020-11-06 12:50:38.443432: 
4749 4f50 0102 0103 1700 0000 0200 0000 GIOP............
0000 7665 0b00 0000 4e61 6d65 5365 7276 ..ve....NameServ
6963 65                                 ice
omniORB: (0) 2020-11-06 12:50:38.443236: omniORB: (0) 2020-11-06 12:50:37.443107: omniORB: (0) 2020-11-06 12:50:38.444269: inputMessage: from giop:tcp:10.0.0.247:2809 20 bytes
omniORB: (0) 2020-11-06 12:50:38.444312: 
4749 4f50 0102 0104 0800 0000 0200 0000 GIOP............
0100 0000                               ....
omniORB: (0) 2020-11-06 12:50:38.444395: Send codeset service context: (ISO-8859-1,UTF-16)
omniORB: (0) 2020-11-06 12:50:38.444426: sendChunky: to giop:tcp:10.0.0.247:2809 92 bytes
omniORB: (0) 2020-11-06 12:50:38.444439: 
4749 4f50 0102 0100 5000 0000 0400 0000 GIOP....P.......
0300 0000 0000 0000 0b00 0000 4e61 6d65 ............Name
5365 7276 6963 6578 1100 0000 6269 6e64 Servicex....bind
5f6e 6577 5f63 6f6e 7465 7874 0069 4f52 _new_context.iOR
0100 0000 0100 0000 0c00 0000 0100 0000 ................
0100 0100 0901 0100 0000 0000           ............
omniORB: (0) 2020-11-06 12:50:38.444419: omniORB: (0) 2020-11-06 12:50:38.444414: JET052
omniORB: (0) 2020-11-06 12:50:38.444914: inputMessage: from giop:tcp:10.0.0.247:2809 80 bytes
omniORB: (0) 2020-11-06 12:50:38.444958: 
4749 4f50 0102 0101 4400 0000 0400 0000 GIOP....D.......
0100 0000 0000 0000 3400 0000 4944 4c3a ........4...IDL:
6f6d 672e 6f72 672f 436f 734e 616d 696e omg.org/CosNamin
672f 4e61 6d69 6e67 436f 6e74 6578 742f g/NamingContext/
496e 7661 6c69 644e 616d 653a 312e 3000 InvalidName:1.0.
./go.sh: line 46: 28855 Segmentation fault      (core dumped) ./eg3_impl

......这就是我看到的回声示例所做的

omniORB: (0) 2020-11-06 12:59:50.031354: LocateRequest to remote: key<NameService>
omniORB: (2) 2020-11-06 12:59:50.031466: AsyncInvoker: thread id 2 has started. Total threads = 2.
omniORB: (2) 2020-11-06 12:59:50.031512: AsyncInvoker: thread id 2 assigned to general tasks. Total general threads = 2.
omniORB: (2) 2020-11-06 12:59:50.031552: AsyncInvoker: thread id 2 performing immediate general task.
omniORB: (2) 2020-11-06 12:59:50.031575: Scavenger task execute.
omniORB: (1) 2020-11-06 12:59:50.081241: SocketCollection idle. Sleeping.
omniORB: (0) 2020-11-06 12:59:51.031650: Client attempt to connect to giop:tcp:10.0.0.247:2809
omniORB: (0) 2020-11-06 12:59:51.031799: Client opened connection to giop:tcp:10.0.0.247:2809
omniORB: (0) 2020-11-06 12:59:51.031812: sendChunky: to giop:tcp:10.0.0.247:2809 35 bytes
omniORB: (0) 2020-11-06 12:59:51.031822: 
4749 4f50 0102 0103 1700 0000 0200 0000 GIOP............
0000 206c 0b00 0000 4e61 6d65 5365 7276 .. l....NameServ
6963 65                                 ice
omniORB: (0) 2020-11-06 12:59:51.031607: omniORB: (0) 2020-11-06 12:59:50.031417: omniORB: (0) 2020-11-06 12:59:51.032369: inputMessage: from giop:tcp:10.0.0.247:2809 20 bytes
omniORB: (0) 2020-11-06 12:59:51.032405: 
4749 4f50 0102 0104 0800 0000 0200 0000 GIOP............
0100 0000                               ....
omniORB: (0) 2020-11-06 12:59:51.032463: Send codeset service context: (ISO-8859-1,UTF-16)
omniORB: (0) 2020-11-06 12:59:51.032505: sendChunky: to giop:tcp:10.0.0.247:2809 119 bytes
omniORB: (0) 2020-11-06 12:59:51.032512: 
4749 4f50 0102 0100 6b00 0000 0400 0000 GIOP....k.......
0300 0000 0000 0000 0b00 0000 4e61 6d65 ............Name
5365 7276 6963 656f 1100 0000 6269 6e64 Serviceo....bind
5f6e 6577 5f63 6f6e 7465 7874 0072 6561 _new_context.rea
0100 0000 0100 0000 0c00 0000 0100 0000 ................
0100 0100 0901 0100 0100 0000 0500 0000 ................
7465 7374 006e 6563 0b00 0000 6d79 5f63 test.nec....my_c
6f6e 7465 7874 00                       ontext.
omniORB: (0) 2020-11-06 12:59:51.032501: omniORB: (0) 2020-11-06 12:59:51.032496: JET052
omniORB: (0) 2020-11-06 12:59:51.033479: inputMessage: from giop:tcp:10.0.0.247:2809 81 bytes
omniORB: (0) 2020-11-06 12:59:51.033528: 
4749 4f50 0102 0101 4500 0000 0400 0000 GIOP....E.......
0100 0000 0000 0000 3500 0000 4944 4c3a ........5...IDL:
6f6d 672e 6f72 672f 436f 734e 616d 696e omg.org/CosNamin
672f 4e61 6d69 6e67 436f 6e74 6578 742f g/NamingContext/
416c 7265 6164 7942 6f75 6e64 3a31 2e30 AlreadyBound:1.0
00                                      .

分析这两次运行时,我注意到损坏代码中的“bind_new_context”消息中缺少“test”和“my_context”的字符串......(这就是命名服务以“无效名称”异常响应的原因)。在断码中,消息更小,消息前面的size字段反映了更小的尺寸。

这与在损坏的代码中没有参数(或使用 NULL 参数)调用“bind_new_context”函数是一致的。但是两个示例都使用相同的源代码;使用相同的 rootContext 和 contextName 变量调用相同的 bind_new_context 函数,并以相同的方式填充。所以我认为我的构建脚本引入了某种环境混淆,而从omniORB编译的版本中不存在。这也可以解释为什么清理代码也被破坏了。但我花了 2 天时间试图摆脱它,但我已经空了。

有任何想法吗?

编辑:这是我基于构建脚本的树的 makefile 的输出。存在差异,但似乎没有实质性的差异。

[jasont@dodeca3 echo]$ make veryclean ; make VERBOSE=1
rm -f eg1 eg2_impl eg2_clt eg3_impl eg3_clt \
    eg3_tieimpl
rm -f *.o *.a 
rm -f *.d
rm -f *.pyc
rm -f ../../../stub/echo.idl ../../../stub/echo.hh ../../../stub/echoSK.cc ../../../stub/echoDynSK.cc ../../../stub/echoSK.o ../../../stub/echoDynSK.o ../../../stub/echoSK.d ../../../stub/echoDynSK.d ../../../stub/dir.mk 
dir=../../../stub;  if [ ! -d $dir ]; then (umask 022; set -x; ../../../../bin/scripts/omkdirhier $dir); fi
rm -f ../../../stub/echo.idl
../../../bin/omniidl -bcxx -Wba -Wbtp -C../../../stub  ../../../../idl/echo.idl
../../../bin/omkdepend -D__cplusplus -D__GNUG__ -D__GNUC__ -D__OMNIORB4__ -I../../../stub -D_REENTRANT -I. -I../../../../src/examples/echo -I../../../include -I../../../../include -D__OSVERSION__=2 -D__linux__ -D__x86_64__ ../../../../src/examples/echo/eg3_clt.cc ../../../../src/examples/echo/eg3_impl.cc ../../../../src/examples/echo/eg2_clt.cc ../../../../src/examples/echo/eg2_impl.cc ../../../../src/examples/echo/eg1.cc
g++ -c -O2 -Wall -Wno-unused -fexceptions  -D__OMNIORB4__ -I../../../stub -D_REENTRANT -I. -I../../../../src/examples/echo -I../../../include -I../../../../include -D__OSVERSION__=2 -D__linux__ -D__x86_64__ -o eg1.o ../../../../src/examples/echo/eg1.cc

cd ../../../stub
make[1]: Entering directory `/home/jasont/FACE_translator/omniORB-4.2.3/build2/stub'
../bin/omkdepend -D__cplusplus -D__GNUG__ -D__GNUC__ -D__OMNIORB4__ -I../stub -D_REENTRANT -I. -I. -I../include -I/home/jasont/FACE_translator/omniORB-4.2.3/include -D__OSVERSION__=2 -D__linux__ -D__x86_64__ echoDynSK.cc echoSK.cc
g++ -c -O2 -Wall -Wno-unused -fexceptions  -D__OMNIORB4__ -I../stub -D_REENTRANT  -I. -I. -I../include -I/home/jasont/FACE_translator/omniORB-4.2.3/include -D__OSVERSION__=2 -D__linux__ -D__x86_64__ -o echoSK.o echoSK.cc
make[1]: Leaving directory `/home/jasont/FACE_translator/omniORB-4.2.3/build2/stub'
+ rm -f eg1
+ g++ -o eg1 -O2 -Wall -Wno-unused -fexceptions -L../../../lib -L../../../../lib eg1.o ../../../stub/echoSK.o -lomniORB4 -lomnithread -lpthread
g++ -c -O2 -Wall -Wno-unused -fexceptions  -D__OMNIORB4__ -I../../../stub -D_REENTRANT -I. -I../../../../src/examples/echo -I../../../include -I../../../../include -D__OSVERSION__=2 -D__linux__ -D__x86_64__ -o eg2_impl.o ../../../../src/examples/echo/eg2_impl.cc
+ rm -f eg2_impl
+ g++ -o eg2_impl -O2 -Wall -Wno-unused -fexceptions -L../../../lib -L../../../../lib eg2_impl.o ../../../stub/echoSK.o -lomniORB4 -lomnithread -lpthread
g++ -c -O2 -Wall -Wno-unused -fexceptions  -D__OMNIORB4__ -I../../../stub -D_REENTRANT -I. -I../../../../src/examples/echo -I../../../include -I../../../../include -D__OSVERSION__=2 -D__linux__ -D__x86_64__ -o eg2_clt.o ../../../../src/examples/echo/eg2_clt.cc
+ rm -f eg2_clt
+ g++ -o eg2_clt -O2 -Wall -Wno-unused -fexceptions -L../../../lib -L../../../../lib eg2_clt.o ../../../stub/echoSK.o -lomniORB4 -lomnithread -lpthread
g++ -c -O2 -Wall -Wno-unused -fexceptions  -D__OMNIORB4__ -I../../../stub -D_REENTRANT -I. -I../../../../src/examples/echo -I../../../include -I../../../../include -D__OSVERSION__=2 -D__linux__ -D__x86_64__ -o eg3_impl.o ../../../../src/examples/echo/eg3_impl.cc
+ rm -f eg3_impl
+ g++ -o eg3_impl -O2 -Wall -Wno-unused -fexceptions -L../../../lib -L../../../../lib eg3_impl.o ../../../stub/echoSK.o -lomniORB4 -lomnithread -lpthread
g++ -c -O2 -Wall -Wno-unused -fexceptions  -D__OMNIORB4__ -I../../../stub -D_REENTRANT -I. -I../../../../src/examples/echo -I../../../include -I../../../../include -D__OSVERSION__=2 -D__linux__ -D__x86_64__ -o eg3_clt.o ../../../../src/examples/echo/eg3_clt.cc
+ rm -f eg3_clt
+ g++ -o eg3_clt -O2 -Wall -Wno-unused -fexceptions -L../../../lib -L../../../../lib eg3_clt.o ../../../stub/echoSK.o -lomniORB4 -lomnithread -lpthread
g++ -c -O2 -Wall -Wno-unused -fexceptions  -D__OMNIORB4__ -I../../../stub -D_REENTRANT -I. -I../../../../src/examples/echo -I../../../include -I../../../../include -D__OSVERSION__=2 -D__linux__ -D__x86_64__ -o eg3_tieimpl.o ../../../../src/examples/echo/eg3_tieimpl.cc
+ rm -f eg3_tieimpl
+ g++ -o eg3_tieimpl -O2 -Wall -Wno-unused -fexceptions -L../../../lib -L../../../../lib eg3_tieimpl.o ../../../stub/echoSK.o -lomniORB4 -lomnithread -lpthread
4

0 回答 0