1819794 Members
3541 Online
109607 Solutions
New Discussion юеВ

SIGBUS bus error

 
tommy_28
Frequent Advisor

SIGBUS bus error

Running a CPP compiled file under hpux11.23 got core dump. Use gdb to debug , showed below error msgs:

Program received signal SIGBUS, Bus error (si_code: 1).
0x40000000000c02b0:0 in CRuntimeData::CRuntimeData (this=0x6000000000008c6c)
at ../src/runtimedata.cpp:36
36 CRuntimeData::CRuntimeData()

runtimedata.cpp:36 is:
CRuntimeData::CRuntimeData()
{
/*
pthread_mutex_init(&m_mutexLock,NULL);
pthread_mutex_init(&m_mutexTmpLock,NULL);
pthread_cond_init(&m_mutexCondVariable,NULL);
*/
printf("nCRuntimeData=%d\n",nCRuntimeData);

nCRuntimeData++;
}

What's wrong with this program?
Thanks!

=================makefile================
CC=aCC +DD64 -g -mt
CPP = aCC +DD64 -g -mt
#VBROKERDIR=/home/ibas/soft/vbroker_bak
VPATH=../../common:../avl:../blbase:../devtest:../src:../../base
#ORACLE_HOME=/oracle/8i/u01/app/oracle/product/8.1.5
ORACLE_HOME=/oracle
LDFLAGS =-L$(ORACLE_HOME)/lib -L$(ORACLE_HOME)/rdbms/lib
#DEFS = -D_INCLUDE_LONGLONG -DORACLE -DUSECORBA -DBITS64 -DHPUX_11 -DHPUX_aCC -DINCLUDE_FSTREAM \
-D_REENTRANT -D_KERNEL_THREADS -D_THREAD_SAFE -DTHREAD -D_VIS_LONG_LONG \
-D_VIS_LONG_DOUBLE -D_VIS_UNICODE -D_VIS_STREAM_WCHAR -D_VIS_NO_IOSTREAM_WCHAR -D_VIS_STD
DEFS = -D_INCLUDE_LONGLONG -DORACLE -DUSECORBA -DBITS64 -DHPUX_11 -DHPUX_aCC -DINCLUDE_FSTREAM \
-D_REENTRANT -D_KERNEL_THREADS -D_THREAD_SAFE -DTHREAD -D_VIS_LONG_LONG \
-D_VIS_LONG_DOUBLE -D_VIS_UNICODE -D_VIS_STREAM_WCHAR -D_VIS_NO_IOSTREAM_WCHAR -D_VIS_STD
#DEFS = -D__LP64__ -D__lint -D__cplusplus -D_REENTRANT -DTHREAD
#DEFS = -DBITS64 -DHPUX_11 -DHPUX_aCC -DINCLUDE_FSTREAM -D_REENTRANT -D_KERNEL_THREADS -D_THREAD_SAFE -DTH
READ

# directory that contain oratypes.h and other oci demo program header files
#INCLUDE= $(CCINCLUDES) -I../../Common -I$(ORACLE_HOME)/rdbms/demo -I$(ORACLE_HOME)/rdbms/public -I$(ORACL
E_HOME)/plsql/public -I$(ORACLE_HOME)/network/public
INCLUDE = $(CCINCLUDES) $(DEFS) -I. -I../avl -I../devtest -I../include -I../blbase -I../../base -I$(VBROKE
RDIR)/include -I$(VBROKERDIR)/include/stubs -I../../common

STDCC_LIBS= -ldl -lmm -lstream -lstd_v2
# libraries for linking oci programs
OCISHAREDLIBS= $(ORACLE_HOME)/lib/libclntsh.so.9.0 #-lclient -lmm
OCISTATICLIBS=$(STATICTTLIBS) $(LLIBTHREAD)

COMPILE_CPP =$(CPP) $(INCLUDE)
#LINK =$(CPP) -mt $(LDFLAGS) $(ORACLE_HOME)/lib/libclntsh.so.9.0 -lrwtool_v2
LINK =$(CPP) $(LDFLAGS) $(ORACLE_HOME)/lib/libclntsh.so.9.0 -lrwtool_v2 -Wl,+s -L$(VBROKERDIR)/lib
-lcosnm64_r -lcosev64_r -lorb64_r -lvport64_r

# Add exe filename and source filename
TARGET1= rating

# Add target name
all: $(TARGET1) $(depends) $(lint)

#C++ SOURCE FILES

SRC_CPP =ratingformat.cpp transaction.cpp runtimedata.cpp LoadConfig.cpp \
InvokeBltoCl.cpp comclass.cpp flist.cpp InvokeBC_c.cpp DebugOut.cpp \
Common.cpp String.cpp PtrArray.cpp Array_s.cpp \
ctrlrating.cpp RateFile.cpp RateServer.cpp DataDict.cpp \
servbal.cpp mutex.cpp RollBack.cpp RatingData.cpp service.cpp TestRate.cpp \
rating.cpp priceclasses.cpp ratingclasses.cpp

#C++ OBJECT FILE
OBJ_CPP = $(SRC_CPP:.cpp=.o)

#C SOURCE FILES
SRC_C =

#C++ OBJECT FILES
OBJ_C = $(SRC_C:.c=.o)

#.SUFFIXES: .o .cpp .c .idl
#.idl.cpp:
# idl2cpp -hdr_suffic h -src_suffic cpp Stand.idl

.SUFFIXES: .o .cpp .c
.cpp.o:
$(COMPILE_CPP) -c -o $@ $<
.c.o:
$(COMPILE_C) -c -o $@ $<

# Add target and obj
$(TARGET1):$(OBJ_CPP) $(OBJ_C)
# $(LINK) $(OBJ_CPP) $(OBJ_C) -lzip -o $@
$(LINK) $(OBJ_CPP) $(OBJ_C) -o $@
cp $(TARGET1) /home/ibas/bin/$(TARGET1)

==========================================



2 REPLIES 2
Elmar P. Kolkman
Honored Contributor

Re: SIGBUS bus error

What is the definition of nCRuntimeData?

It seems to me that's where the problem is... And that line 36 is the printf (please confirm). Though it could be the increment line as well.
Every problem has at least one solution. Only some solutions are harder to find.
Mike Stroyan
Honored Contributor

Re: SIGBUS bus error

A SIGBUS is often caused by accessing data at an address that is not aligned to a multiple of the width of the data. A 4 byte int must be aligned on a multiple of 4. An 8 byte long must be aligned on a multiple of 8.

From the limited information available, I would guess that nCRuntimeData is a long and a member of the CRuntimeData class. It may be that CRuntimeData::CRuntimeData was called using a bad pointer to an instance of CRuntimeData. The 'this' address reported by gdb is only aligned on a multiple of 4 bytes. That could happen if the 'new' operator had been redefined with a function that returned addresses with insufficient alignment. It could also be caused by replacing malloc.