LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Segmentation fault (https://www.linuxquestions.org/questions/linux-newbie-8/segmentation-fault-4175601380/)

mevaa 03-09-2017 06:51 AM

Segmentation fault
 
Hi,

I am new in both Linux and NS2. I am working on VirtualBox with Ubuntu i686 GNU/Linux.
I am trying to run a tcl example about adding malicious node to the AODV. I updated the aodv.h and aodv.cc files according to link
http://www.nsnam.com/2014/02/adding-...2-in-aodv.html
Then, I am getting such an error. Also, .tr and .nam file are created in spite of segmentation fault error.

$ nsmal malicious.tcl
num_nodes is set 2
INITIALIZE THE LIST xListHead
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 550.0
SORTING LISTS ...DONE!
Segmentation fault (core dumped)


However, when I run another example, it runs smoothly.
$nsmal demo.tcl
num_nodes is set 12
INITIALIZE THE LIST xListHead
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 550.0
SORTING LISTS ...DONE!

Why it is happening? please, can anyone help?

frankbell 03-10-2017 10:39 PM

I fear that the cause of segmentation faults is quite difficult to diagnose, as they generally produce no useful log entries or error messages.

This might help: http://unix.stackexchange.com/questi...entation-fault

Peverel 03-15-2017 03:37 PM

A segmentation fault occurs when a program attempts to execute an illegal instruction or when the stack overflows. The stack is the memory where most data is kept: it grows when a program requests more data. Stack overflow usually means recursion has failed to stop; possible but unlikely. An illegal instruction is usually caused by an invalid address, outside the data allocated to the program.

You are compiling and running a program, which has a bug in it. I have no idea as to how the program works, but if you have done exactly what you were told to do, then there is a bug in the downloaded program. Check you got the modifications right, exactly as listed, and that you set the malicious node as specified. My guess is that you got the modifications wrong, since I have spent many years programming and teaching programming.

Peverel 03-15-2017 04:10 PM

Sudden thought: if you used = instead of ++ (two equals signs) then that would cause it!
if(strcmp(argv[1], "malicious") == 0) {
malicious = true;
return TCL_OK;
}

if(malicious==true)

mevaa 03-16-2017 05:38 AM

Thank you for your answers.

I changed the tcl file and it works.

knudfl 03-22-2017 01:42 PM

Please mark your question as [SOLVED].


All times are GMT -5. The time now is 04:41 PM.