LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-01-2011, 01:10 AM   #1
naren123.k
Member
 
Registered: Jan 2011
Posts: 85

Rep: Reputation: 17
getting segmentation fault


hi,
while make function i got following errors
./common/ptypes2tcl > gen/ptypes.cc
/bin/sh: line 1: 15769 Segmentation fault ./common/ptypes2tcl > gen/ptypes.cc
make: *** [gen/ptypes.cc] Error 139
[root@localhost ns-2.33]#
can any one tell me how to solve this
 
Old 03-01-2011, 01:15 AM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Try compiling with the -g gcc flag, run gdb ./common/ptypes2tcl and type run at the prompt. When it stops with a segmentation fault, type bt at the prompt, which should tell you what line of code causes the problem. I'm assuming you're using a compiled language with gcc.
Kevin Barry

Last edited by ta0kira; 03-01-2011 at 01:16 AM.
 
Old 03-01-2011, 01:31 AM   #3
naren123.k
Member
 
Registered: Jan 2011
Posts: 85

Original Poster
Rep: Reputation: 17
ok after that i got this
set pvals(52) PGM\n\
set ptype(lms) 53\n\
set pvals(53) LMS\n\
set ptype(lms_setup) 54\n\
set pvals(54) LMS_SETUP\n\
set ptype(sctp) 55\n\
set pvals(55) sctp\n\
set ptype(sctp_app1) 56\n\
set pvals(56) sctp_app1\n\
set ptype(smac) 57\n\
set pvals(57) smac\n\
set ptype(xcp) 58\n\
set pvals(58) xcp\n\
set ptype(hdlc) 59\n\
set pvals(59) HDLC\n\
set ptype(belllabstrace) 60\n\
set pvals(60) BellLabsTrace\n\

Program received signal SIGSEGV, Segmentation fault.
0x0804897a in lcase ()
(gdb) bt
#0 0x0804897a in lcase ()
#1 0x08048a45 in main ()
(gdb)
 
Old 03-01-2011, 01:52 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2015, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 15,334

Rep: Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939
Quote:
[root@localhost ns-2.33]#
You are not supposed to use root ( su ) for any ns2 commands.

Install all ns2 in /home/<usr-name/ , like
/home/<usr-name/ns2/ns-allinone-2.34/ns-2.33/
/home/<usr-name/ns2/ns-allinone-2.34/ns-2.34/
... then all commands can be done as 'unprivileged user'.

And it is still not clear, what you are trying to do.
Please show all the commands, you are using.

..

Last edited by knudfl; 03-01-2011 at 09:31 AM.
 
Old 03-01-2011, 02:15 AM   #5
naren123.k
Member
 
Registered: Jan 2011
Posts: 85

Original Poster
Rep: Reputation: 17
i am trying to run one protocol that i downloaded from net and during make i got segmentation fault.. as given above
i am doing this in fedora 7...i installed NS2.34, in that i am working
 
Old 03-04-2011, 01:25 AM   #6
naren123.k
Member
 
Registered: Jan 2011
Posts: 85

Original Poster
Rep: Reputation: 17
can i continue this thread
 
Old 03-04-2011, 03:36 AM   #7
naren123.k
Member
 
Registered: Jan 2011
Posts: 85

Original Poster
Rep: Reputation: 17
i am getting segmentation fault in /ns-2.33/common/ptypes2tcl
which is executable file.. i can edit ptypes2tcl.cc but how can correct problem in executable files like ptypes2tcl..???
 
Old 03-04-2011, 04:26 AM   #8
naren123.k
Member
 
Registered: Jan 2011
Posts: 85

Original Poster
Rep: Reputation: 17
how to solve this segmentation problem

hi,
i am strucked at this segmentation problem since two days i tried all possible ways...as /ns-2.33/common/ptypes2tcl is an executable file i don't know where to edit plz help me..

g++ -Wl,-export-dynamic -o common/ptypes2tcl common/ptypes2tcl.o
./common/ptypes2tcl > gen/ptypes.cc
/bin/sh: line 1: 6588 Segmentation fault ./common/ptypes2tcl > gen/ptypes.cc
make: *** [gen/ptypes.cc] Error 139
[root@localhost ns-2.33]#
 
Old 03-04-2011, 06:32 AM   #9
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Quote:
Originally Posted by naren123.k View Post
hi,
as /ns-2.33/common/ptypes2tcl is an executable file i don't know where to edit plz help me..
You need to edit the source code (not the executable) once you found the root cause of your segmentation fault.

Quote:
Originally Posted by naren123.k View Post
./common/ptypes2tcl > gen/ptypes.cc
/bin/sh: line 1: 6588 Segmentation fault ./common/ptypes2tcl > gen/ptypes.cc
Do you see a core file? Do you have the source cod available? I would then analyze the core file or run your executable in a live GDB session to check where the problem comes from. Unfortunately, it's hard to give a more precise advice without any details ...

Andi
 
Old 03-04-2011, 06:50 AM   #10
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 730

Rep: Reputation: 175Reputation: 175
ptypes2tcls
http://www-rp.lip6.fr/ns-doc/ns226-d...es2tcl_8cc.htm
http://www-rp.lip6.fr/ns-doc/ns226-d...8cc-source.htm

Make says error 139.
http://stason.org/TULARC/os/linux-fa...Error-139.html
 
Old 03-04-2011, 07:02 AM   #11
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2015, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 15,334

Rep: Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939
When you edit a c++ file like ptypes2tcl.cc :
cd ns-allinone-2.33/ns-2.33/ &&
cp ns ns.org ( or whatever name, you'd prefer.)
make clean && make : Then you get a new binary 'ns' with the corrected function.

'ns' is the executable.
The tcl files are scripts ( non executable ) interpreted by 'ns'.
Also : ptypes2.tcl is an easy editable text file. But is probably OK ?

..
 
Old 03-05-2011, 01:11 AM   #12
naren123.k
Member
 
Registered: Jan 2011
Posts: 85

Original Poster
Rep: Reputation: 17
plz follow the link

http://www-rp.lip6.fr/ns-doc/ns226-d...8cc-source.htm

i found following extra code in ns2.33/common/ptypes2tcl.cc

char** p_info::name_;
unsigned int p_info::nPkt_ = 0;
PacketClassifier *p_info:c_ = 0;
int p_info::addPacket(char *name)
{
if(!nPkt_)
initName();

int newID = nPkt_-1;
PT_NTYPE = nPkt_;
initName();
name_[newID] = name;
return newID;
}

after following Mr.ta0kira i found segmentation fault in below case
#0 0x0804897a in lcase ()
#1 0x08048a45 in main ()

can you solve this now??

Last edited by naren123.k; 03-05-2011 at 01:12 AM.
 
Old 03-05-2011, 06:51 AM   #13
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,270

Rep: Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163
The point of failure is this line of code
Code:
sprintf(strbuf, "set ptype(%s) %d", lcase(pinfo.name(packet_t(i))), i);
Something is seriously wrong with pinfo.name(packet_t(61)) causing a crash inside lcase

You posted a very relevant looking chunk of code, but I still don't see enough info to figure out how everything fits together:
Code:
int p_info::addPacket(char *name)
{
   if(!nPkt_)
      initName();

   int newID = nPkt_-1;
   PT_NTYPE = nPkt_;
   initName();
   name_[newID] = name;
   return newID;
}
If that function had been called with a name that is null or otherwise bad, or with a name that only exists temporarily, that would easily explain the crash. (That function stores the name that the failing code is reading).

But I don't seen anything indicating that function is called at all. You still haven't posted or linked enough to see where the bad name comes from.

Last edited by johnsfine; 03-05-2011 at 07:10 AM.
 
Old 03-05-2011, 09:56 AM   #14
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2015, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 15,334

Rep: Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939Reputation: 2939
ptypes2tcl.cc is the second link in post # 10 ( April 2004 version.)

The file ptypes2tcl.cc in ns-2.33 is quite different. ( Is attached.)

..
Attached Files
File Type: txt ptypes.cc.txt (3.7 KB, 106 views)
File Type: txt ptypes2tcl.cc.txt (2.0 KB, 48 views)
 
Old 02-24-2014, 07:23 AM   #15
Chakraborty
Member
 
Registered: Jan 2014
Location: India
Distribution: Linux-(Ubuntu 12.04,14.04.02). 32-bit for Research
Posts: 84

Rep: Reputation: Disabled
Segmentation fault...

Quote:
Originally Posted by knudfl View Post
ptypes2tcl.cc is the second link in post # 10 ( April 2004 version.)

The file ptypes2tcl.cc in ns-2.33 is quite different. ( Is attached.)

..



Dear Knudfl,

I am trying to patch GPSR with ns-2.33, at Ubuntu 12.04.
Now I am stuck with segmentation fault, as given below.

g++ -Wl,-export-dynamic -o common/ptypes2tcl common/ptypes2tcl.o
./common/ptypes2tcl > gen/ptypes.cc
Segmentation fault (core dumped)
make: *** [gen/ptypes.cc] Error 139
root@chakraborty-desktop:/home/chakraborty/ns/ns-allinone-2.33/ns-2.33#


I had referred the thread and tried to find the fault by using gdb mand I got the following result

root@chakraborty-desktop:/home/chakraborty/ns/ns-allinone-2.33/ns-2.33# gdb ./common/ptypes2tcl
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/chakraborty/ns/ns-allinone-2.33/ns-2.33/common/ptypes2tcl...(no debugging symbols found)...done.
(gdb) run
Starting program: /home/chakraborty/ns/ns-allinone-2.33/ns-2.33/common/ptypes2tcl
static const char code[] = "\n\
global ptype pvals\n\
set ptype(error) -1\n\
set pvals(-1) error\n\
set ptype(tcp) 0\n\
set pvals(0) tcp\n\
..................
.....................
....................
set pvals(57) smac\n\
set ptype(xcp) 58\n\
set pvals(58) xcp\n\
set ptype(hdlc) 59\n\
set pvals(59) HDLC\n\
set ptype(belllabstrace) 60\n\
set pvals(60) BellLabsTrace\n\

Program received signal SIGSEGV, Segmentation fault.
0x080489b5 in lcase(char const*) ()
(gdb) bt
#0 0x080489b5 in lcase(char const*) ()
#1 0x08048a6e in main ()

I examined the code but could not find the fault, also matched it with your linked files in #14

http://www.linuxquestions.org/questi...roblem-866379/

Should I go for compiler Upgrade.
Please help me in this regard.

With Thanks.

Last edited by Chakraborty; 02-24-2014 at 07:26 AM. Reason: Unnecessaary words
 
  


Reply

Tags
c/c++, 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
how to solve solve broken shell problem prasanth.george Red Hat 1 01-21-2011 09:48 AM
Segmentation fault error on UrbanTerror4 dedicated2 ┐how to solve it? ElPeruanoFamoso Linux - Server 0 06-09-2007 03:32 PM
trying to solve a problem... kiasta Linux - General 5 06-28-2006 06:36 PM
help..how i can solve this problem?// TAAN Linux - General 2 02-16-2005 07:53 AM
Who can help me to solve this problem? Annie0716 Programming 2 08-09-2004 07:59 PM


All times are GMT -5. The time now is 06:43 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