PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

FAQ: "Backtrace" causes a seg fault when compiled

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



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

PostPosted: Tue Oct 21, 2008 1:26 pm    Post subject: FAQ: "Backtrace" causes a seg fault when compiled Reply with quote

Hi All,

I wanted to share the following report sent in to PGI customer support. The user was trying to use the "backtrace" function in a static binary causing the code to seg fault. For example:
Code:

bicycle:/tmp% cat back.c
#include <stdio.h>
#include <execinfo.h>
int
main ( int argc, char *argv [] )
{
    int num_pcs;
    void *pcs [ 32 ];
    setvbuf ( stdout, 0, _IONBF, 0 );
    printf ( "calling backtrace\n" );
    num_pcs = backtrace ( pcs, sizeof ( pcs ) / sizeof ( pcs [ 0 ] ) );
    printf ( "back\n" );
    return 0;
}
bicycle:/tmp% pgcc -Bstatic back.c
bicycle:/tmp% a.out
calling backtrace
Segmentation fault (core dumped)


There are two problems here. The first was the we (PGI) weren't linking the correct crtbegin.o object which included static traceback (crtbeginT.o). While this was fixed with the 7.2 release, the same code will still seg fault on systems that use GCC 3.3.3. This is a problem with crtbeginT.o itself which was fixed with later versions of GCC.

If you encounter this problem either don't statically link system files when using backtrace (i.e. link with -Bstatic_pgi which statically links the PGI libraries but not the system libraries.) or update your PGI and GCC versions.

Hope this helps,
- Mat
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