By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

"compile" problem

P: n/a
I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...:
g++ packet.cpp radix.cpp route.cpp -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, class Sockaddr *Dst, class Sockaddr *Gateway, class
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;
class 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
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Alexander Bartzas" <am******@ee.duth.gr> wrote in message
news:be**********@nic.grnet.gr...
I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...:
g++ packet.cpp radix.cpp route.cpp -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, class Sockaddr *Dst, class Sockaddr *Gateway, class
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;
class 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


The normal way to solve this kind of problem is to use a debugger. Since you
are using g++ you should look at the gdb debugger. Most likely reason for
your crash is that ifa or rt are a NULL or otherwise invalid pointers. As
for why that should be, well the debugger will help you work it out.

john
Jul 19 '05 #2

P: n/a
"Alexander Bartzas" <am******@ee.duth.gr> wrote...
I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...:
g++ packet.cpp radix.cpp route.cpp -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, class Sockaddr *Dst, class Sockaddr *Gateway, class
Sockaddr *Netmask, int flags, class rtentry **ret_nrt)
{
register class rtentry *rt;
'rt' here is a pointer to an object of type 'rtentry'. Which
object does it point to? Unknown. You didn't make it point
anywhere. It's uninitialised. Its value is random garbage.
register class radix_node *rn;
register class radix_node_head *rnh;
struct ifaddr *ifa;
'ifa' here is a pointer to some object of type 'ifaddr'. What
object does it point to? Unknown. Because it doesn't have
any value.
class Sockaddr *Ndst;
...
What's here? I presume there is nothing here that changes
the values of 'rt' or 'ifa'.

rt->rt_ifp = (struct ifnet *) ifa->ifa_ifp;
Here you dereference both 'rt' and 'ifa'. An attempt to
dereference a pointer whose value is garbage leads to what
you get, a segmentation fault. In terms of C++ you witness
"undefined behaviour".

...}

rt_ifp is of type struct ifnet *

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


You need to make those pointers point somewhere real. Perhaps
you could find an example of what you're trying to accomplish.
Try looking on the Web. Neither 'rtentry', nor 'ifaddr' is
a standard type, so we cannot really help you give them correct
values.

Victor
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.