Click to See Complete Forum and Search --> : help! error message at pthread_create


natxie
February 23rd, 2006, 11:47 PM
My program crashed with "bus error" message.
I ran it under valgrind, I got the following error message, but I couldn't figure out what's wrong. Please help!

==15351==
==15351== Syscall param write(buf) points to uninitialised byte(s)
==15351== at 0x1B91BE5B: write (in /lib/libpthread-0.10.so)
==15351== by 0x8065C0B: iret::CServer_pth::run_pth(iret::Nabor_pth*, iret::Bool_pth*, iret::BnBayes_pth*, iret::Focus_pth*, iret::Slice_Accpth*) (CServer.C:138)
==15351== by 0x804B02C: main (Srv_lyhgu.C:46)
==15351== Address 0x52BFE1AC is on thread 1's stack

Line CServer.C:138 is calling "pthread_create" function. The code is:

....
#define NUM_THR 5
pthread_t srvtid[NUM_THR];
static int* tdata[NUM_THR];
static pthread_attr_t thread_attr;
pthread_attr_init(&thread_attr);

for (i=0; i<NUM_THR; i++) {
tdata[i] = new int;
pthread_create(&srvtid[i], &thread_attr, commsrv_pth,tdata[i])) ----> line #138
}
extern "C" void *commsrv_pth(void *argp) {
....
}

zerver
March 14th, 2006, 08:40 AM
Hi!

"bus error" usually occurs when you try to access data at an address that is incorrectly aligned. For example, an integer (= 4 bytes) must be located at an address that is divisible by 4.

Check if you can find any obvious errors of this kind.

Cheers / Z