Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pthread_create crashing

30 views
Skip to first unread message

Jeff

unread,
Jan 1, 2010, 2:11:07 PM1/1/10
to
Ive used this same code in the past and recently
started working on something new. Its now crashing
on pthread_create, but seems to point to memory allocation
as the problem in gdb:

(gdb) bt
#0 __libc_calloc (n=18, elem_size=8) at malloc.c:4049
#1 0x0079146c in allocate_dtv (result=<value optimized out>) at dl-
tls.c:300
#2 *__GI__dl_allocate_tls (result=<value optimized out>) at dl-tls.c:
466
#3 0x0094b27e in allocate_stack (stack=<value optimized out>,
pdp=<value optimized out>, attr=<value optimized out>) at
allocatestack.c:561
#4 __pthread_create_2_1 (stack=<value optimized out>, pdp=<value
optimized out>,
attr=<value optimized out>) at pthread_create.c:436
#5 0x0804ad21 in ServFD::Start (this=0x80545e8) at ServFD.cpp:617

pthread_t m_tid;
extern "C" {

inline static void *start_thread(void *args)
{
ServFD * const serv = (ServFD *)(args);

serv->Run();

serv->~ServFD();
return 0;
}
};

This is inside the ServFD::Start() C++ method where 'this' is ServFD:

int ret = pthread_create(&m_tid, NULL, start_thread, this);

Im running on fedora 12, g++ (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)
2GB memory, not running much of anything on machine, top shows
about 1G RAM free, 0 swap used.

Like I said, I know this same code worked before and Im seeing
it fail on 2 machines (both running Fed 12). I dont have a Fed 11
machine to try or I would.

Anyone seen this and know how to fix or work around?


David Schwartz

unread,
Jan 1, 2010, 11:36:47 PM1/1/10
to
On Jan 1, 11:11 am, Jeff <j...@rahul.net> wrote:

> Anyone seen this and know how to fix or work around?

Can you create a complete self-contained, compilable example that
demonstrates the problem? Most likely, the bug is in code you have not
shown. (And you may want to use tools like 'valgrind' to check for
heap corruption.)

DS

Jeff

unread,
Jan 2, 2010, 12:10:08 AM1/2/10
to

Thanks, I used valgrind and found my error which was a bug
in the previous version and just happened to work all this time.
I didnt initialize the namelen variable in getpeername(). Im such
a proponent of valgrind and I didnt think to use it in this case.

Thanks again

0 new messages