bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AIX 5.3 executable faults if included net/if_arp.h


From: Suresh Pedamallu
Subject: AIX 5.3 executable faults if included net/if_arp.h
Date: Wed, 08 Dec 2010 16:05:00 -0000
User-agent: G2/1.0

On AIX 5.3 i am trying to run a binary that is compiled with g++ but
it is giving segmentation fault. The details are as follows.
The example source code is spread across test.h, test.cpp, test1.cpp
and main.cpp
-bash-3.00# cat test.cpp
#include "test.h"

std::string globalString = "Venky" ;
void setGlobal( const std::string& temp )
{
        globalString = temp ;
}

void printGlobal( )
{
        std::cout << globalString << std::endl ;
}

-bash-3.00# cat test.h
#  include <net/if.h>

#include <iostream>
#include <string>
void setGlobal( const std::string& temp ) ;
void printGlobal() ;
class Test
{
        public:
        Test() ;
        static std::string staticString ;

        void setStatic( const std::string& temp ) ;
        void printStatic () ;
} ;
-bash-3.00# cat test1.cpp
#include "test.h"

std::string Test::staticString = "BSR" ;
Test::Test()
{}

void Test::setStatic( const std::string& temp )
{
        staticString = temp ;
}

void Test::printStatic()
{
        std::cout << staticString << std::endl ;
}

-bash-3.00# cat main.cpp
#include "test.h"

int main()
{

        printGlobal() ;
        setGlobal( "123456" ) ;

        Test test;
        test.printStatic() ;
        test.setStatic( "QWERT" ) ;

        printGlobal();
        test.printStatic();
}

The commands used to build the binary are as below:
g++ -c -DDEBUG -O0 -g3 -fno-optimize-sibling-calls -fno-omit-frame-
pointer  -g3 -ggdb -DSV_UNIX -DSV_AIX -DSTDC_HEADERS -DHAVE_UNISTD_H -
DHAVE_SIGACTION -DHAV
E_SETSID -DHAVE_STRCASECMP -DHAVE_NETDB_H -DHAVE_NETINET_H -
D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64  -
DVSNAP_USER_MODE test.cpp
ar r libtest.a test.o
g++ -c -DDEBUG -O0 -g3 -fno-optimize-sibling-calls -fno-omit-frame-
pointer  -g3 -ggdb -DSV_UNIX -DSV_AIX -DSTDC_HEADERS -DHAVE_UNISTD_H -
DHAVE_SIGACTION -DHAV
E_SETSID -DHAVE_STRCASECMP -DHAVE_NETDB_H -DHAVE_NETINET_H -
D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64   -
DVSNAP_USER_MODE     test1.
cpp
ar r libtest1.a test1.o
g++ -c  -DDEBUG -O0 -g3 -fno-optimize-sibling-calls -fno-omit-frame-
pointer  -g3 -ggdb -DSV_UNIX -DSV_AIX -DSTDC_HEADERS -DHAVE_UNISTD_H -
DHAVE_SIGACTION -DHA
VE_SETSID -DHAVE_STRCASECMP -DHAVE_NETDB_H -DHAVE_NETINET_H -
D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -
DVSNAP_USER_MODE  main.cpp
g++ -L. main.o -o main -ltest -ltest1

The /usr/include/net/if_arp.h file has a structure declared like:
struct  fc_softc {
  int a ; //struct arpcom   fc_ac;              /* FCS common
part             */
  int b ; //struct ndd    *nddp;                /* returned from
NS            */
  int(*efcnet_arp_fct)
  (struct ndd *, struct mbuf *); /* efcnet_arp function address */
  }; *fc_softc ; //====> having this here is resulting in segmentation
fault.
and it found to be resulting in segmentation fault. The static
variables in the library are not getting initialized (their
constructors are not called) and when the segmentation fault while
accessing the objects. The address of those static objects are showing
as 0x0 in the gdb.

The problem seems to be with g++. I also tried to have a look at the
same header file in AIX 6.1 and it is same as in 5.3.

I tried to search for any patch in IBM website but I didn't find any.

As a temporary fix the above structure in /usr/include/net/if_arp.h
has changed to
typedef struct __fc_softc {
struct arpcom fc_ac; /* FCS common part */
struct ndd nddp; / returned from NS */
int(*efcnet_arp_fct)
(struct ndd *, struct mbuf ); / efcnet_arp function address */
} *fc_softrc ;
For now the above structure in net/if_arp.h header file is changed as


But we never know similar structures are used in any other system
headers.. Is there any g++ patch available for this?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]