PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

How to use -Mchkstk with a pthread program in Linux?

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
gman168



Joined: 10 May 2007
Posts: 3

PostPosted: Thu Oct 31, 2013 7:45 am    Post subject: How to use -Mchkstk with a pthread program in Linux? Reply with quote

HI,

I am trying to use -Mchkstk to compile a pthread program. However, it prints an stack overflow message and then exits the program.

Error: in routine foo there is a
stack overflow: thread 0, max 8180KB, used 1KB, request 64B

i.e. max is 8MB and the request is only 64 bytes. How could stack overflow happen?

Based on the message, I don't understand why there is a stack overflow. I searched various documentation, faq, google and I cannot find an answer.

May be I did not compile the program with the proper flags.
I used the following (and other variations):

pgcc -mp -Mchkstk -lpthread -o a a.c
pgcc -Mchkstk -lpthread -o a a.c
...

They all printed stack overflow.

My test program is pretty simple:


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

static void* foo(void* inp);

int main (
int argc,
char* argv[])
{
pthread_t pt;
pthread_attr_t attr;
void* rv;

pthread_attr_init (&attr);
pthread_attr_setstacksize (&attr, 1024 * 64);

fprintf (stderr, "%s %d\n", __FILE__, __LINE__);
if (pthread_create (&pt, (void*)&attr, foo, NULL) == 0)
{
pthread_join (pt, &rv);
printf ("rv=%p\n", rv);
}
fprintf (stderr, "%s %d\n", __FILE__, __LINE__);

return 0;
}


static void* foo (void* inp)
{
char table_name[64];

strcpy (table_name, "dk3djfdlkjfldsjfldkfdsf");
fprintf (stderr, "%s %d %s\n", __FILE__, __LINE__, table_name);
return 0;
}

pgcc --version
pgcc 13.9-0 64-bit target on x86-64 Linux -tp p7
The Portland Group - PGI Compilers and Tools
Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.

Does -Mchkstk work with pthread at all?
If it does, how do I make the above program to run?

Thanks.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6119
Location: The Portland Group Inc.

PostPosted: Fri Nov 01, 2013 12:50 pm    Post subject: Reply with quote

Hi gman168,


I sent this on to engineering for a better understanding on what's happening. I'll post as I know more.

- Mat
Back to top
View user's profile
gman168



Joined: 10 May 2007
Posts: 3

PostPosted: Mon Nov 04, 2013 8:19 am    Post subject: Reply with quote

mkcolg wrote:
Hi gman168,


I sent this on to engineering for a better understanding on what's happening. I'll post as I know more.

- Mat


Thank you, Mat.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6119
Location: The Portland Group Inc.

PostPosted: Wed Nov 06, 2013 2:08 pm    Post subject: Reply with quote

Hi gman168,

I talked with our compiler architect about this. "-Mchkstk" was never intended for use with pthreads so not a supported feature.

Sorry,
Mat
Back to top
View user's profile
gman168



Joined: 10 May 2007
Posts: 3

PostPosted: Wed Nov 06, 2013 2:29 pm    Post subject: Reply with quote

mkcolg wrote:
Hi gman168,

I talked with our compiler architect about this. "-Mchkstk" was never intended for use with pthreads so not a supported feature.

Sorry,
Mat


Thanks.

It is the message that was confusing. It would be less confusing if it prints something like "-Mchkstk with pthread is not supported". A warning/limitation in the documentation would even be better. If that was the case, I would not spend time to investigate how to make it works.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group