"compile" problem

Discussion in 'C Programming' started by Alexander Bartzas, Jul 8, 2003.

  1. I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...:

    > cc packet.c radix.c route.c -o route


    There is no problem in the compilation of the code but when I try to run
    it...

    Segmentation fault (core dumped)

    I've located where the problem is... It is part of the following function's
    code:

    int rtrequest(int req, struct sockaddr *Dst, struct sockaddr *Gateway,
    struct sockaddr *Netmask, int flags, class rtentry **ret_nrt)
    {
    register class rtentry *rt;
    register class radix_node *rn;
    register class radix_node_head *rnh;
    struct ifaddr *ifa;
    struct sockaddr *Ndst;
    ....

    rt->rt_ifp = (struct ifnet *) ifa->ifa_ifp;

    ....}

    rt_ifp is of type struct ifnet *

    I don't what to do to overcome the problem.
    Any help is welcomed.
    Thanks in advance
    Alexander Bartzas
    Alexander Bartzas, Jul 8, 2003
    #1
    1. Advertising

  2. Alexander Bartzas

    Default User Guest

    Alexander Bartzas wrote:


    > register class rtentry *rt;


    What is this supposed to be? You haven't defined the terms class or
    rtentry.


    > rt->rt_ifp = (struct ifnet *) ifa->ifa_ifp;



    Where was the pointer rt set to point to a valid object? Since you
    skipped part of the code we can't tell. Why did you do that? If you knew
    what the problem was, then you wouldn't need help.




    Brian Rodenborn
    Default User, Jul 8, 2003
    #2
    1. Advertising

  3. Alexander Bartzas

    Derk Gwen Guest

    # Segmentation fault (core dumped)

    # rt->rt_ifp = (struct ifnet *) ifa->ifa_ifp;

    # I don't what to do to overcome the problem.

    Did you verify rt and ifa are valid pointers? You can do something like
    fprintf(stderr,"rt=%p ifa=%p\n",rt,ifa);
    on most machines they will be nonzeros and even numbers, perhaps multiples
    of four. (Most machines represent null with zeros. Many machines require
    pointers to be aligned; even if not aligned pointers can still be more
    efficient and preferred.)

    --
    Derk Gwen http://derkgwen.250free.com/html/index.html
    Why are we here?
    whrp
    Derk Gwen, Jul 8, 2003
    #3
  4. On Tue, 08 Jul 2003 21:46:56 -0000, Derk Gwen <>
    wrote:

    ># Segmentation fault (core dumped)
    >
    ># rt->rt_ifp = (struct ifnet *) ifa->ifa_ifp;
    >
    ># I don't what to do to overcome the problem.
    >
    >Did you verify rt and ifa are valid pointers? You can do something like
    > fprintf(stderr,"rt=%p ifa=%p\n",rt,ifa);


    You need to cast each of the pointers to void* to insure that fprintf
    can process them correctly.

    >on most machines they will be nonzeros and even numbers, perhaps multiples
    >of four. (Most machines represent null with zeros. Many machines require
    >pointers to be aligned; even if not aligned pointers can still be more
    >efficient and preferred.)




    <<Remove the del for email>>
    Barry Schwarz, Jul 13, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nagaraj
    Replies:
    1
    Views:
    854
    Lionel B
    Mar 1, 2007
  2. timjowers
    Replies:
    7
    Views:
    4,339
    heyjude
    Feb 2, 2011
  3. Replies:
    1
    Views:
    448
    Cowboy \(Gregory A. Beamer\)
    Apr 11, 2008
  4. Carter
    Replies:
    2
    Views:
    501
    Carter
    Mar 4, 2009
  5. fAnSKyer
    Replies:
    2
    Views:
    530
    Alf P. Steinbach
    Jun 7, 2009
Loading...

Share This Page