f



Purify problem or compiler problem? #2

Hi,

I am using sun's CC (c++ compiler) to compile the follow code:

#define __REENTRANT
#include <stdio.h>
#include <pthread.h>

void *one(void *dummy);

void two(void);
void output(void);

int main (int argc, char **argv)
{
        pthread_t tid;
        pthread_create( &tid, NULL, one, NULL );
        pthread_join(tid,NULL);
}

void *one(void *dummy)
{
        output();
        two();
        return NULL;
}

void two(void)
{
        output();
}

void output(void)
{
        //char string[16468]; //This one purify likes
        //char string[16469]={0}; //This and greater makes purify spit
BSW's
        char string[16469]; //This and greater makes purify spit a
IPW/R's
        string[0]='\0';
}

This is purify's output:

IPW: Invalid pointer write
      This is occurring while in thread 7:
            void output()  [testmain3.o]
            void two()     [testmain3.o]
            void*one(void*) [testmain3.o]
            _thread_start  [libthread.so.1]
      Writing 1 byte to 0x7e5fbbef on the stack of thread 7.
      Address 0x7e5fbbef is    16473 bytes below frame pointer in
function void output().
     
 Thread Summary : 7 threads in existence
         Thread 0 [main thread]
         Stack Limit : (0xff3f0000 0xffbf0000), size = 0x800000
         Thread 1
         Stack Limit : (0x7ef10000 0x7f010000), size = 0x100000
         Stack Use : (0x7f00fa30 0x7f00fd54), size = 0x324
         Thread 2
         Stack Limit : (0x7e652000 0x7e656000), size = 0x4000
         Stack Use : (0x7e655978 0x7e655d54), size = 0x3dc
         Thread 3
         Stack Limit : (0x7f902b64 0x7f91e3f8), size = 0x1b894
         Stack Use : (0x7f9076d0 0x7f9078f4), size = 0x224
         Thread 4
         Stack Limit : (0x7ee0e000 0x7ef0e000), size = 0x100000
         Stack Use : (0x7ef0db30 0x7ef0dd54), size = 0x224
         Thread 6
         Stack Limit : (0x7e612000 0x7e616000), size = 0x4000
         Stack Use : (0x7e615b28 0x7e615d54), size = 0x22c
         Thread 8
         Stack Limit : (0x7e632000 0x7e634000), size = 0x2000
         Stack Use : (0x7e633b28 0x7e633d54), size = 0x22c

This is with CC. With gcc or g++ it does not have this problem. cc has
the problem too but with a larger number in the array.

Is it the compiler/linker bug or it purify making things up?

If it is the compiler I assume I am screwing up memory badly.

Matt
0
matt13 (6)
2/6/2004 12:35:05 PM
comp.unix.solaris 26025 articles. 2 followers. Post Follow

2 Replies
912 Views

Similar Articles

[PageSpeed] 26

matt@holly.com.au (Matthew) writes:

>This is purify's output:

>IPW: Invalid pointer write
>      This is occurring while in thread 7:
>            void output()  [testmain3.o]
>            void two()     [testmain3.o]
>            void*one(void*) [testmain3.o]
>            _thread_start  [libthread.so.1]
>      Writing 1 byte to 0x7e5fbbef on the stack of thread 7.
>      Address 0x7e5fbbef is    16473 bytes below frame pointer in
>function void output().


Is this compiled with "-O"?  Does the compiler perhaps generate
a leaf routine?  (No framepointer)

Casper
0
Casper
2/6/2004 2:09:33 PM
In article <16800e49.0402060435.4af957b5@posting.google.com>, Matthew wrote:
....
> This is with CC. With gcc or g++ it does not have this problem. cc has
> the problem too but with a larger number in the array.
> 
> Is it the compiler/linker bug or it purify making things up?
> 
> If it is the compiler I assume I am screwing up memory badly.
> 
> Matt

Which version compiler (-V will print it out) 
and what options are you using ?
Could be a mismatch between purify and compiler version.
Also the code doesn't seem to create 7 threads...how come you end up with 9 ?

Seongbae
0
Seongbae
2/13/2004 9:49:26 PM
Reply: