LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-09-2017, 06:51 AM   #1
mevaa
LQ Newbie
 
Registered: Mar 2017
Posts: 4

Rep: Reputation: Disabled
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?
 
Old 03-10-2017, 10:39 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 15,443
Blog Entries: 25

Rep: Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447
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
 
1 members found this post helpful.
Old 03-15-2017, 03:37 PM   #3
Peverel
Member
 
Registered: May 2009
Location: Chelmsford, England
Distribution: OpenSuse 12.2 and 13.2, Leap 4.2
Posts: 125

Rep: Reputation: 24
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.

Last edited by Peverel; 03-15-2017 at 03:39 PM. Reason: removing possible misunderstanding
 
1 members found this post helpful.
Old 03-15-2017, 04:10 PM   #4
Peverel
Member
 
Registered: May 2009
Location: Chelmsford, England
Distribution: OpenSuse 12.2 and 13.2, Leap 4.2
Posts: 125

Rep: Reputation: 24
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)
 
Old 03-16-2017, 05:38 AM   #5
mevaa
LQ Newbie
 
Registered: Mar 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thank you for your answers.

I changed the tcl file and it works.
 
Old 03-22-2017, 01:42 PM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2019 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,269

Rep: Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568Reputation: 3568
Please mark your question as [SOLVED].
 
  


Reply

Tags
ns2, segmentation fault ns2


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation Fault zkhuhr Programming 2 08-21-2008 06:34 AM
why segmentation fault? nanxy Programming 7 07-30-2008 12:46 PM
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
Segmentation fault? JiggaJerry Fedora 10 01-16-2005 04:01 PM
Segmentation Fault monojit_18 Programming 1 12-12-2004 11:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration