f



Purify problem or compiler problem?

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:30:39 PM
comp.lang.c 30657 articles. 4 followers. spinoza1111 (3246) is leader. Post Follow

6 Replies
877 Views

Similar Articles

[PageSpeed] 49

Matthew <matt@holly.com.au> spoke thus:

> I am using sun's CC (c++ compiler) to compile the follow code:
> #include <pthread.h>
> This is purify's output:

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

(All this suggests that you'd be better served in a more topical
newsgroup.)

Your post is off-topic for comp.lang.c.  Please visit

http://www.csclub.uwaterloo.ca/u/dj3vande/clc/clc-welcome.txt
http://www.eskimo.com/~scs/C-faq/top.html
http://benpfaff.org/writings/clc/off-topic.html

for posting guidelines and frequently asked questions.  Thank you.

-- 
Christopher Benson-Manica  | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org    | don't, I need to know.  Flames welcome.
0
ataru (1609)
2/6/2004 1:21:46 PM
Matthew wrote:

> 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


man pthread_attr_setstackaddr

/J
0
johan9496 (19)
2/7/2004 2:45:07 PM
Johan Lindh wrote:

> Matthew wrote:
> 
>> 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
> 
> 
> 
> man pthread_attr_setstackaddr
> 
> /J

Uh, I meant

man pthread_attr_setstacksize

...(of course :P)

0
johan9496 (19)
2/7/2004 2:46:04 PM
Johan Lindh wrote:
> 
> Johan Lindh wrote:

> > man pthread_attr_setstackaddr
> >
> > /J
> 
> Uh, I meant
> 
> man pthread_attr_setstacksize

Do you know any newsgroups where threads are on topic ?

-- 
pete
0
pfiland (6613)
2/7/2004 3:39:41 PM
pete wrote:

> Johan Lindh wrote:
> 
>>Johan Lindh wrote:
> 
> 
>>>man pthread_attr_setstackaddr
>>>
>>>/J
>>
>>Uh, I meant
>>
>>man pthread_attr_setstacksize
> 
> 
> Do you know any newsgroups where threads are on topic ?
> 

Sure!
alt.sex.spam

0
johan9496 (19)
2/7/2004 3:42:00 PM
Johan Lindh wrote:
> 
> pete wrote:
> 
> > Johan Lindh wrote:
> >
> >>Johan Lindh wrote:
> >
> >
> >>>man pthread_attr_setstackaddr
> >>>
> >>>/J
> >>
> >>Uh, I meant
> >>
> >>man pthread_attr_setstacksize
> >
> >
> > Do you know any newsgroups where threads are on topic ?
> >
> 
> Sure!
> alt.sex.spam

Then take your discussion to there.

-- 
pete
0
pfiland (6613)
2/7/2004 3:56:57 PM
Reply: