bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Linux, multithreading and gdb problem.


From: slawomir grajewski
Subject: Linux, multithreading and gdb problem.
Date: Fri, 16 Feb 2001 00:53:25 -0800 (PST)

Hello,

I have problems with debugging multi-threaded
application with dbg under Linux RedHat 6.2. The
below program runs perfectly well without gdb. Under
gdb (no breakpoints set) the
program terminates in either of the two assert()
statements - sleep() calls get interrupted. I'm
desperately
looking for the answer why.

I appreciate any help,
Slawek

#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <assert.h>

void *
thread_routine(void *a)
{
  unsigned int ret;

  printf("Started\n");

  ret = sleep(5);
  assert(ret == 0);            /* !!!!!!!!!!!!!!!!!!!!
HERE (ret is equal 5)
!!!!!!!!!!!!!!!!!!!!!!! */

  printf("Stopped\n");

  return NULL;
}

int
main(void)
{
  pthread_t pid;
  int i;
  int ret;

  /* we start with default attributes ... */
  for (i = 0; i < 10; i++)
    pthread_create(&pid, NULL, thread_routine, NULL);

  ret = sleep(10);
  assert(ret == 0);        /* !!!!!!!!!!!!!!!!!!!!
HERE (ret is equal 10)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */

  return 0;
}




__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]