Mailinglist Archive: opensuse-ppc (38 mails)

< Previous Next >
Re: [suse-ppc] GDB thinks stack is corrupt.
  • From: Sid <sid.raghunathan@xxxxxxxxx>
  • Date: Wed, 3 Aug 2005 14:18:44 -0500
  • Message-id: <92f68aca05080312181b308ade@xxxxxxxxxxxxxx>
On 8/2/05, Olaf Hering <olh@xxxxxxx> wrote:
> Do you have a simple testcase to demonstrate the problem?

The sample from this bug report works quite well. This is another bug
that I ran into, but it demonstrates gdb's confusion quite well.

I am porting over a significant codebase from AIX and not having
backtrace is a major pain. I am also using XLC, but the problem seems
to not constricted to XLC, since i compiled this with g++.

Here's a capture from a session which includes a listing of the program.
$ cat pthread2.cpp
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <unistd.h>

myThread(void* arg)
printf("**** Success, created thread exiting\n");

return (0);

main(int argc,
char** argv)
pthread_attr_t attr;
int priority = 0;
struct sched_param schedParam;
int status;
pthread_t threadId;

schedParam.sched_priority = priority;
if (pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) != 0)
printf("pthread_attr_setinheritsched failed\n");
else if (pthread_attr_setschedpolicy(&attr, SCHED_OTHER) != 0)
printf("pthread_attr_setschedpolicy failed\n");
else if (pthread_attr_setschedparam(&attr, &schedParam) != 0)
printf("pthread_attr_setschedparam failed\n");
printf("Will create thread with priority %d\n", priority);
status = pthread_create(&threadId, &attr, myThread, 0);
printf("Thread creation returned %d\n", status);


printf("Main thread exiting\n");

return (0);
$ g++ -g -lpthread -o run pthread2.cpp
$ gdb run
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "ppc-suse-linux"...Using host libthread_db
library "/lib/tls/".

(gdb) break myThread
Breakpoint 1 at 0x100006ac: file pthread2.cpp, line 10.
(gdb) run
Starting program: /home/sr9690/test/srvcoretest/run
[Thread debugging using libthread_db enabled]
[New Thread 1074001984 (LWP 12491)]
Will create thread with priority 0
[New Thread 1078197024 (LWP 12494)]
Thread creation returned 0
[Switching to Thread 1078197024 (LWP 12494)]

Breakpoint 1, myThread (arg=0x0) at pthread2.cpp:10
10 printf("**** Success, created thread exiting\n");
(gdb) bt
#0 myThread (arg=0x0) at pthread2.cpp:10
#1 0x0ffe3048 in start_thread () from /lib/tls/
#2 0x0fda9dd8 in clone () from /lib/tls/
#3 0x0fda9dd8 in clone () from /lib/tls/
Previous frame identical to this frame (corrupt stack?)

Thanks for your help

< Previous Next >
List Navigation
Follow Ups