之前leader分了我个coredump的bug,从客户给的gdb bt中看不到任何有用的信息,也没有core dump文件生成。
$ gdb makepwe.exe
Starting program: /proj/BTESAT2/bin/makepwe.exe
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000001 in ?? ()
(gdb) bt
#0 0x0000000000000001 in ?? ()
#1 0x00007fffffffbd4b in ?? ()
#2 0x0000000000000000 in ?? ()
自己只能一点一点跟了,但是更奇怪的是他根本就没有执行到main函数就coredump了。所以感觉不是code的原因,也许是编译选项的问题。所以去找了一下别的客户(linux上的)可以运行成功不coredump的程序:
c catcr $ARBORBIN/makepwe.exe
Derived object: /usr1/arbor/bin/makepwe.exe@@--05-13T21:29.62576
Target /usr1/arbor/bin/makepwe.exe built by yanl03.clearusr
Host "dcmvrh12" running Linux 2.6.32-279.el6.x86_64 (x86_64)
View was dcmvrh12:/CCSEVIEW/helen.telus.bp12.5_fx2.5_mnt_dcmvrh12
Initial working directory was /usr1/arbor/oam_src/security/applications
----------------------------
MVFS objects:
----------------------------
/usr1/arbor/bin/makepwe.exe@@--05-13T21:29.62576
/usr1/arbor/camb_src/lib/libarbor_utils.so@@--05-13T21:00.35051020
/usr1/arbor/denver_src/make_sys/makefile.arborversion@@/main/13
/usr1/arbor/oam_src/security/applications/makepwe.o@@--05-13T21:29.54370953
----------------------------
Variables and Options:
----------------------------
ARBORSRC=/usr1/arbor/src
CC_MT=gcc -DARBORBP -Wimplicit-function-declaration -fPIC -DLINUX -DBT_UNIX -DBT_LINUX -m64 -DBUILD64BIT -pthread -D_REENTRANT
CFLAGS=-g -I/usr1/arbor/src/include
FLAG=
FLG_OBJ=-o
LIBRARIES=-larbor_utils
LIBRARY_DIRS=-L/usr1/arbor/src/lib -L/usr1/arbor/3p/oracle/LINUX/lib -L/usr/ccs/lib -L/usr/lib64 -L/usr/local/lib -L/usr1/arbor/site_specific/lib
MAKE=clearmake -C gnu
MAKEPWE_EXE=/usr1/arbor/bin/makepwe.exe
MAKEPWE_OBJ=makepwe.o
----------------------------
Build Script:
----------------------------
@(rm -f arbor_version.c; clearmake -C gnu -f /usr1/arbor/src/make_sys/makefile.arborversion)
gcc -DARBORBP -Wimplicit-function-declaration -fPIC -DLINUX -DBT_UNIX -DBT_LINUX -m64 -DBUILD64BIT -pthread -D_REENTRANT -g -I/usr1/arbor/src/include makepwe.o -L/usr1/arbor/src/lib -L/usr1/arbor/3p/oracle/LINUX/lib -L/usr/ccs/lib -L/usr/lib64 -L/usr/local/lib -L/usr1/arbor/site_specific/lib -larbor_utils -o /usr1/arbor/bin/makepwe.exe
----------------------------
但是coredump的却多了个-shared 的option
gcc -DARBORBP -Wimplicit-function-declaration -fPIC -DLINUX -DBT_UNIX -DBT_LINUX -m64 -DBUILD64BIT -pthread -D_REENTRANT -g -I/usr1/arbor/src/include <span style="background-color: rgb(255, 102, 102);">-shared</span> makepwe.o -L/usr1/arbor/src/lib -L/opt/app/oracle/product/11.2.0.3/lib -L/usr/ccs/lib -L/usr/lib64 -L/usr/local/lib -L/usr1/arbor/site_specific/lib -larbor_utils -o /usr1/arbor/bin/makepwe.exe
也许有可能是这个编译选项的关系,我在Makefile中去掉这个编译选项后进行编译,果真不coredump了。
[/usr1/arbor/oam_src/security/applications](103)yyang@dcmvrh12#c desc makefile
version "makefile@@/main/rl_fx2.2_addm/rl_bt_ireland_fx2.2_00_ebf/1"
"PR# CBS00153556 Binary makepwe.exe crashes with core dump CBS00153556"
Element Protection:
User : vobadm : r--
Group: arboradm : r--
Other: : r--
element type: text_file
predecessor version: /main/rl_fx2.2_addm/rl_bt_ireland_fx2.2_00_ebf/0
Attributes:
PRNUM = "CBS00153556"
[/usr1/arbor/oam_src/security/applications] (104)yyang@dcmvrh12#diff makefile@@/main/rl_fx2.2_addm/rl_bt_ireland_fx2.2_00_ebf/1 makefile@@/main/rl_fx2.2_addm/rl_bt_ireland_fx2.2_00_ebf/0
56c56
< CFLAGS = $(DEFAULT_CFLAGS)
---
> CFLAGS = $(DEFAULT_CFLAGS) -shared
-shared 该选项指定生成动态连接库(让连接器生成T类型的导出符号表,有时候也生成弱连接W类型的导出符号),不用该标志外部程序无法连接。相当于一个可执行文件。