Operating System - HP-UX
1748136 Members
3593 Online
108758 Solutions
New Discussion

App crashes(SIGSEGV, Segmentation fault) on HP-UX on introducing a new structure member

 
wini008
Occasional Contributor

App crashes(SIGSEGV, Segmentation fault) on HP-UX on introducing a new structure member

Hi All,

 

I am executing my own application which is built on HPUX Itanium platfrom with g++ compiler 3.4.4. The system deatiails are as follows:

 

#uname -a

HP-UX xy1600 B.11.23 U ia64 3100475210 unlimited-user license

 

This application contains a structure declaration in its C++ code. The structure declaration is as follows;

#define S_ID_LENGTH 32

#define L_MAX_LENGTH 2

#define C_TYPE_LENGTH 127

 

typedef struct {


    char* pData;
    const char* rDir;
    const char* loc;
    char sessionID[S_ID_LENGTH+1];
    const char* URL;
    char* args;
    char* method;
    const char* clientIP;
    char localeType[L_MAX_LENGTH+1];
    char contentType[C_TYPE_LENGTH+1];
    char cacheControl[C_TYPE_LENGTH+1];


} RequestRec;

This successfully runs fine, but when i introduce a new structure member inside this structure declaration, the application crashes.

 

New structure after introducing the new variable:

 

typedef struct {


    char* pData;
    const char* rDir;
    const char* loc;
    char sessionID[S_ID_LENGTH+1];
    const char* URL;
    char* args;
    char* method;
    const char* clientIP;
    char localeType[L_MAX_LENGTH+1];
    char contentType[C_TYPE_LENGTH+1];
    char cacheControl[C_TYPE_LENGTH+1];

    char userName[MAX_CONTENT_TYPE_LENGTH+1];  /* Newly introduced member */


} RequestRec;

 

The back trace of the core dump is as follows:

 

 

Program received signal SIGSEGV, Segmentation fault
  si_code: 1 - SEGV_MAPERR - Address not mapped to object.
[Switching to thread 27 (system thread 3085163)]
warning: No unwind information found.
 Skipping this library /lib/hpux64/libcl.so.1.

search ()
    at ../../../../../core/libs/libc/shared_em_64/../core/gen/getcwd.c:589
589     ../../../../../core/libs/libc/shared_em_64/../core/gen/getcwd.c: No such file or directory.
        in ../../../../../core/libs/libc/shared_em_64/../core/gen/getcwd.c
(gdb) bt
#0  search ()
    at ../../../../../core/libs/libc/shared_em_64/../core/gen/getcwd.c:589
#1  0x9fffffffec05e7f0:0 in getcwd ()
    at ../../../../../core/libs/libc/shared_em_64/../core/gen/getcwd.c:868
#2  0x40000000009d42d0:0 in fnplm::lmgrd::File::getCurrentDirectory()+0x40 ()

 

Eventhough i am not accessing the new variable anywhere in the code, just declaraing a new member inside the structure causes the application to crash. The same application works fine if i change the optimization level to Os and dynamically allocate the memory to new structure member(char * userName) instead of declaring inside the structure(as  char userName[C_TYPE_LENGTH+1]) .

 

Can anybody tell me the reason for getting this crash, just by introducing a new variable inside the structure? How this works fine just by changing the Optimization level and dynamically allocating the memory to newly introduced member?

 

How can i introduce a new variable(character array) without changing the Optimization level?

 

NOTE: This behaviour is observed only on HP-UX Platfrom.

 

Thanks & Regards,

Vinay

 

3 REPLIES 3
Dennis Handly
Acclaimed Contributor

Re: App crashes(SIGSEGV, Segmentation fault) on HP-UX on introducing a new structure member

>when I introduce a new structure member inside this structure declaration, the application crashes.

 

If you change the size of a struct, you need to recompile/relink all objects that use that struct.

 

>Even though I am not accessing the new variable anywhere in the code,

 

That doesn't matter.  You can't access the struct.

 

>How can I introduce a new variable(character array)

 

Have you tried cleaning and rebuilding everything?

 

>#1  0x9fffffffec05e7f0:0 in getcwd

 

What is being passed to getcwd(3)?  Are the parms reasonable  Anything related to that struct?

 

>warning: No unwind information found.   Skipping this library /lib/hpux64/libcl.so.1.

 

Any reason you are linking against this empty shlib?

wini008
Occasional Contributor

Re: App crashes(SIGSEGV, Segmentation fault) on HP-UX on introducing a new structure member

Yes. I cleaned and rebuilt everything.

I am not passing any parameter related to struct to getcwd(3).

 

How does changing the Optimization level to Os and dynamically allocating memory to the variable helps in solving the issue?

 

Dennis Handly
Acclaimed Contributor

Re: App crashes(SIGSEGV, Segmentation fault) on HP-UX on introducing a new structure member

>I am not passing any parameter related to struct to getcwd(3).

 

Are you passing a valid address and length?

 

>How does changing the optimization level and dynamically allocating memory to the variable help in solving the issue?

 

That probably doesn't solve the problem, it just hides it.  Perhaps there is an uninitialized variable and the different code generated has a different value.  Or the heap layout is now different.