Aborted (core dumped) while running DCCP

1k Views Asked by At

I am trying to run this TCL Script which is a DCCP implementation,

set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac)   Mac/802_11
set val(ifq)   Queue/DropTail/PriQueue
set val(ll)    LL
set val(ant)   Antenna/OmniAntenna
set val(ifqlen) 50
set val(nn)     3 
set val(rp)     AODV
set val(x)      500
set val(y)      500
set val(stop)   150







#-------Event scheduler object creation--------#

set ns              [new Simulator]
#creating trace file and nam file
set tracefd       [open dccp1.tr w]
#set windowVsTime2 [open cp1.tr w]
set namtrace      [open dccp1.nam w]   

$ns use-newtrace
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

# set up topography object
set topo       [new Topography]

$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)

# configure the nodes
        $ns node-config -adhocRouting $val(rp) \
                   -llType $val(ll) \
                   -macType $val(mac) \
                   -ifqType $val(ifq) \
                   -ifqLen $val(ifqlen) \
                   -antType $val(ant) \
                   -propType $val(prop) \
                   -phyType $val(netif) \
                   -channelType $val(chan) \
                   -topoInstance $topo \
                   -agentTrace ON \
                   -routerTrace ON \
                   -macTrace OFF \
                   -movementTrace ON

      for {set i 0} {$i < $val(nn) } { incr i } {
            set node_($i) [$ns node]     
      }

# Provide initial location of mobilenodes
$node_(0) set X_ 5.0
$node_(0) set Y_ 5.0
$node_(0) set Z_ 0.0

$node_(1) set X_ 490.0
$node_(1) set Y_ 285.0
$node_(1) set Z_ 0.0

$node_(2) set X_ 150.0
$node_(2) set Y_ 240.0
$node_(2) set Z_ 0.0

# Generation of movements
$ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0"
$ns at 15.0 "$node_(1) setdest 45.0 285.0 5.0"
$ns at 19.0 "$node_(2) setdest 480.0 300.0 5.0"

# Set a DCCP connection between node_(0) and node_(1)



# DCCP agent 
set dccp [new Agent/DCCP/TCPlike]
$dccp set class_ 2
set dccpsink [new Agent/DCCP/TCPlike]
$ns attach-agent $node_(0) $dccp
$ns attach-agent $node_(1) $dccpsink
$ns connect $dccp $dccpsink
#set cbr1 [new Application/Traffic/CBR]
#$cbr1 attach-agent $dccp
#$cbr1 set packetSize_ 1024
#$cbr1 set rate_ 1024Kb
#$cbr1 set random_ rng 
#$ns at 10.0 "$cbr1 start"

set ftp [new Application/FTP]
$ftp attach-agent $dccp
$ftp set packetSize_ 1024Kb
$ftp set rate_ 1024Kb
$ns at 10.0 "$ftp start"


set dccp1 [new Agent/DCCP/TCPlike]
$dccp1 set class_ 2
set dccpsink1 [new Agent/DCCP/TCPlike]
$ns attach-agent $node_(1) $dccp1
$ns attach-agent $node_(2) $dccpsink1
$ns connect $dccp1 $dccpsink1
#set cbr1 [new Application/Traffic/CBR]
#$cbr1 attach-agent $dccp
#$cbr1 set packetSize_ 1024
#$cbr1 set rate_ 1024Kb
#$cbr1 set random_ rng 
#$ns at 10.0 "$cbr1 start"


set ftp1 [new Application/FTP]
$ftp1 attach-agent $dccp1
$ftp1 set packetSize_ 1024Kb
$ftp1 set rate_ 1024Kb
$ns at 10.0 "$ftp1 start"

$ns at 0.0 "$dccpsink listen"

$ns at 0.0 "$dccpsink1 listen"







# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam
$ns initial_node_pos $node_($i) 150
}

# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
    $ns at $val(stop) "$node_($i) reset";
}

# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 150.01 "puts \"end simulation\" ; $ns halt"
proc stop {} {
    global ns tracefd namtrace
    $ns flush-trace
    close $tracefd
    close $namtrace
exec nam dccp1.nam &
}

$ns run

On running this code, my terminal shows an Aborted (core dumped) error. The exact error is,

num_nodes is set 3
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
INITIALIZE THE LIST xListHead
*** buffer overflow detected ***: ns terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f07f6c3f7e5]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7f07f6ce056c]
/lib/x86_64-linux-gnu/libc.so.6(+0x116570)[0x7f07f6cde570]
/lib/x86_64-linux-gnu/libc.so.6(+0x1158c2)[0x7f07f6cdd8c2]
ns(_ZN8CMUTrace10nam_formatEP6Packeti+0x92)[0x5c9842]
ns(_ZN8CMUTrace6formatEP6PacketPKc+0x45)[0x5ca065]
ns(_ZN8CMUTrace4recvEP6PacketP7Handler+0x33)[0x5ca243]
ns(_ZN9DCCPAgent6outputEb+0x257)[0x5550a7]
ns(_ZN5Agent7commandEiPKPKc+0x4a2)[0x518362]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x263d)[0x7f07f7be363d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeObjectCommand+0x102)[0x7f07f786acc2]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x276d)[0x7f07f7be376d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeObjectCommand+0x102)[0x7f07f786acc2]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x263d)[0x7f07f7be363d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(+0x3bd15)[0x7f07f786dd15]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(Tcl_EvalEx+0x13)[0x7f07f786d5f3]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(Tcl_Eval+0x15)[0x7f07f786e7f5]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(Tcl_GlobalEval+0x23)[0x7f07f786f8e3]
/usr/lib/x86_64-linux-gnu/libtclcl.so.1(_ZN3Tcl4evalEPc+0x12)[0x7f07f7df3342]
ns(_ZN9AtHandler6handleEP5Event+0x12)[0x504012]
ns(_ZN9Scheduler3runEv+0x36)[0x504a16]
ns(_ZN9Scheduler7commandEiPKPKc+0x38c)[0x5055bc]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x263d)[0x7f07f7be363d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeObjectCommand+0x102)[0x7f07f786acc2]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x276d)[0x7f07f7be376d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeObjectCommand+0x102)[0x7f07f786acc2]
/usr/lib/x86_64-linux-gnu/libotcl.so.1(+0x263d)[0x7f07f7be363d]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclInvokeStringCommand+0x76)[0x7f07f786ab96]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(TclNRRunCallbacks+0x47)[0x7f07f786cfa7]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(+0x3bd15)[0x7f07f786dd15]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(Tcl_FSEvalFileEx+0x258)[0x7f07f7926ca8]
/usr/lib/x86_64-linux-gnu/libtcl8.6.so(Tcl_MainEx+0x257)[0x7f07f792e417]
ns(nslibmain+0x22)[0x6a7a12]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f07f6be8830]
ns[0x4fb9de]
======= Memory map: ========
00400000-007aa000 r-xp 00000000 08:06 1836802                            /usr/bin/ns
009aa000-009ab000 r--p 003aa000 08:06 1836802                            /usr/bin/ns
009ab000-00a2a000 rw-p 003ab000 08:06 1836802                            /usr/bin/ns
00a2a000-00a36000 rw-p 00000000 00:00 0 
01464000-019cd000 rw-p 00000000 00:00 0                                  [heap]
7f07f5a75000-7f07f5a80000 r-xp 00000000 08:06 2498347                    /lib/x86_64-linux-gnu/libnss_files-2.23.so
7f07f5a80000-7f07f5c7f000 ---p 0000b000 08:06 2498347                    /lib/x86_64-linux-gnu/libnss_files-2.23.so
7f07f5c7f000-7f07f5c80000 r--p 0000a000 08:06 2498347                    /lib/x86_64-linux-gnu/libnss_files-2.23.so
7f07f5c80000-7f07f5c81000 rw-p 0000b000 08:06 2498347                    /lib/x86_64-linux-gnu/libnss_files-2.23.so
7f07f5c81000-7f07f5c87000 rw-p 00000000 00:00 0 
7f07f5c87000-7f07f5c92000 r-xp 00000000 08:06 2498327                    /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7f07f5c92000-7f07f5e91000 ---p 0000b000 08:06 2498327                    /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7f07f5e91000-7f07f5e92000 r--p 0000a000 08:06 2498327                    /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7f07f5e92000-7f07f5e93000 rw-p 0000b000 08:06 2498327                    /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7f07f5e93000-7f07f5ea9000 r-xp 00000000 08:06 2498338                    /lib/x86_64-linux-gnu/libnsl-2.23.so
7f07f5ea9000-7f07f60a8000 ---p 00016000 08:06 2498338                    /lib/x86_64-linux-gnu/libnsl-2.23.so
7f07f60a8000-7f07f60a9000 r--p 00015000 08:06 2498338                    /lib/x86_64-linux-gnu/libnsl-2.23.so
7f07f60a9000-7f07f60aa000 rw-p 00016000 08:06 2498338                    /lib/x86_64-linux-gnu/libnsl-2.23.so
7f07f60aa000-7f07f60ac000 rw-p 00000000 00:00 0 
7f07f60ac000-7f07f60b4000 r-xp 00000000 08:06 2498339                    /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7f07f60b4000-7f07f62b3000 ---p 00008000 08:06 2498339                    /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7f07f62b3000-7f07f62b4000 r--p 00007000 08:06 2498339                    /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7f07f62b4000-7f07f62b5000 rw-p 00008000 08:06 2498339                    /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7f07f62b5000-7f07f658d000 r--p 00000000 08:06 1835929                    /usr/lib/locale/locale-archive
7f07f658d000-7f07f65a5000 r-xp 00000000 08:06 2498337                    /lib/x86_64-linux-gnu/libpthread-2.23.so
7f07f65a5000-7f07f67a4000 ---p 00018000 08:06 2498337                    /lib/x86_64-linux-gnu/libpthread-2.23.so
7f07f67a4000-7f07f67a5000 r--p 00017000 08:06 2498337                    /lib/x86_64-linux-gnu/libpthread-2.23.so
7f07f67a5000-7f07f67a6000 rw-p 00018000 08:06 2498337                    /lib/x86_64-linux-gnu/libpthread-2.23.so
7f07f67a6000-7f07f67aa000 rw-p 00000000 00:00 0 
7f07f67aa000-7f07f67c3000 r-xp 00000000 08:06 2495741                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7f07f67c3000-7f07f69c2000 ---p 00019000 08:06 2495741                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7f07f69c2000-7f07f69c3000 r--p 00018000 08:06 2495741                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7f07f69c3000-7f07f69c4000 rw-p 00019000 08:06 2495741                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7f07f69c4000-7f07f69c7000 r-xp 00000000 08:06 2498330                    /lib/x86_64-linux-gnu/libdl-2.23.so
7f07f69c7000-7f07f6bc6000 ---p 00003000 08:06 2498330                    /lib/x86_64-linux-gnu/libdl-2.23.so
7f07f6bc6000-7f07f6bc7000 r--p 00002000 08:06 2498330                    /lib/x86_64-linux-gnu/libdl-2.23.so
7f07f6bc7000-7f07f6bc8000 rw-p 00003000 08:06 2498330                    /lib/x86_64-linux-gnu/libdl-2.23.so
7f07f6bc8000-7f07f6d87000 r-xp 00000000 08:06 2498331                    /lib/x86_64-linux-gnu/libc-2.23.so
7f07f6d87000-7f07f6f87000 ---p 001bf000 08:06 2498331                    /lib/x86_64-linux-gnu/libc-2.23.so
7f07f6f87000-7f07f6f8b000 r--p 001bf000 08:06 2498331                    /lib/x86_64-linux-gnu/libc-2.23.so
7f07f6f8b000-7f07f6f8d000 rw-p 001c3000 08:06 2498331                    /lib/x86_64-linux-gnu/libc-2.23.so
7f07f6f8d000-7f07f6f91000 rw-p 00000000 00:00 0 
7f07f6f91000-7f07f6fa7000 r-xp 00000000 08:06 2495588                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f07f6fa7000-7f07f71a6000 ---p 00016000 08:06 2495588                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f07f71a6000-7f07f71a7000 rw-p 00015000 08:06 2495588                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7f07f71a7000-7f07f7319000 r-xp 00000000 08:06 1837190                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f07f7319000-7f07f7519000 ---p 00172000 08:06 1837190                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f07f7519000-7f07f7523000 r--p 00172000 08:06 1837190                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f07f7523000-7f07f7525000 rw-p 0017c000 08:06 1837190                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f07f7525000-7f07f7529000 rw-p 00000000 00:00 0 
7f07f7529000-7f07f7631000 r-xp 00000000 08:06 2498336                    /lib/x86_64-linux-gnu/libm-2.23.so
7f07f7631000-7f07f7830000 ---p 00108000 08:06 2498336                    /lib/x86_64-linux-gnu/libm-2.23.so
7f07f7830000-7f07f7831000 r--p 00107000 08:06 2498336                    /lib/x86_64-linux-gnu/libm-2.23.so
7f07f7831000-7f07f7832000 rw-p 00108000 08:06 2498336                    /lib/x86_64-linux-gnu/libm-2.23.so
7f07f7832000-7f07f79d1000 r-xp 00000000 08:06 1845656                    /usr/lib/x86_64-linux-gnu/libtcl8.6.so
7f07f79d1000-7f07f7bd1000 ---p 0019f000 08:06 1845656                    /usr/lib/x86_64-linux-gnu/libtcl8.6.so
7f07f7bd1000-7f07f7bdf000 r--p 0019f000 08:06 1845656                    /usr/lib/x86_64-linux-gnu/libtcl8.6.so
7f07f7bdf000-7f07f7be0000 rw-p 001ad000 08:06 1845656                    /usr/lib/x86_64-linux-gnu/libtcl8.6.so
7f07f7be0000-7f07f7be1000 rw-p 00000000 00:00 0 
7f07f7be1000-7f07f7beb000 r-xp 00000000 08:06 1835928                    /usr/lib/x86_64-linux-gnu/libotcl.so.1.14
7f07f7beb000-7f07f7dea000 ---p 0000a000 08:06 1835928                    /usr/lib/x86_64-linux-gnu/libotcl.so.1.14
7f07f7dea000-7f07f7deb000 r--p 00009000 08:06 1835928                    /usr/lib/x86_64-linux-gnu/libotcl.so.1.14
7f07f7deb000-7f07f7dec000 rw-p 0000a000 08:06 1835928                    /usr/lib/x86_64-linux-gnu/libotcl.so.1.14
7f07f7dec000-7f07f7df9000 r-xp 00000000 08:06 1836475                    /usr/lib/x86_64-linux-gnu/libtclcl.so.1.20
7f07f7df9000-7f07f7ff9000 ---p 0000d000 08:06 1836475                    /usr/lib/x86_64-linux-gnu/libtclcl.so.1.20
7f07f7ff9000-7f07f7ffa000 r--p 0000d000 08:06 1836475                    /usr/lib/x86_64-linux-gnu/libtclcl.so.1.20
7f07f7ffa000-7f07f802a000 rw-p 0000e000 08:06 1836475                    /usr/lib/x86_64-linux-gnu/libtclcl.so.1.20
7f07f802a000-7f07f802c000 rw-p 00000000 00:00 0 
7f07f802c000-7f07f8052000 r-xp 00000000 08:06 2495505                    /lib/x86_64-linux-gnu/ld-2.23.so
7f07f822d000-7f07f8235000 rw-p 00000000 00:00 0 
7f07f824e000-7f07f8251000 rw-p 00000000 00:00 0 
7f07f8251000-7f07f8252000 r--p 00025000 08:06 2495505                    /lib/x86_64-linux-gnu/ld-2.23.so
7f07f8252000-7f07f8253000 rw-p 00026000 08:06 2495505                    /lib/x86_64-linux-gnu/ld-2.23.so
7f07f8253000-7f07f8254000 rw-p 00000000 00:00 0 
7ffd24410000-7ffd24432000 rw-p 00000000 00:00 0                          [stack]
7ffd245a2000-7ffd245a4000 r--p 00000000 00:00 0                          [vvar]
7ffd245a4000-7ffd245a6000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted (core dumped)

The .tr and .nam files are generated empty. I tried to run simple TCL Scripts with NAM and they all executed fine. Please check whether I am missing something or there is a problem with my installation of ns. I tried installing mannasim, but was unsuccessful in doing so. Please state clear steps to correct my installation of the software or the correction of code.

2

There are 2 best solutions below

0
On BEST ANSWER

I solved the issue to some extent. The problem was that I had an older version of ns2 previously installed. Hence the newer ns2.35 was not able to work. I used this command to uninstall previously installed ns.

rishabh@Rishabh:~$ sudo apt-get purge --auto-remove ns

Still, a Segmentation Fault occurs in the end, but the nam output is generated fine.

2
On

Well, the crash is happening inside the C library (which doesn't seem to have debugging symbols on your system, making guessing what is wrong tricky), but the caller into that is the code for NS. The key line from the stack trace is this:

ns(_ZN8CMUTrace10nam_formatEP6Packeti+0x92)[0x5c9842]

Now, that's a C++ mangled name inside the parentheses (they're obvious with a little experience). With a little help from an online service, it can be decoded to:

CMUTrace::nam_format(Packet*, int)

It's 0x92 (= 146) bytes into that function that this other call is; you could disassemble things to figure out what's going on there, but it should be a call into the C library. Probably to sprintf or something like that.

The other functions on the stack at that point from NS are:

CMUTrace::format(Packet*, char const*)
CMUTrace::recv(Packet*, Handler*)
DCCPAgent::output(bool)
Agent::command(int, char const* const*)

Then there's what must be a thunk function in OTcl, and then you're into Tcl's own code. Now, you're using Tcl 8.6 so the trace isn't very useful (due to the non-recursive execution engine) but I'm guessing it is handling a callback out of the simulator core (because of _ZN9AtHandler6handleEP5Event — translated as AtHandler::handle(Event*) — further down-stack) that was registered with at. Hard to say exactly what is going on.

You'll need a debugger and full source code to hunt this further. It's beyond what you usually get from a Stack Overflow answer.


Other cheap things you could try…

You could try doing this early in your code to ensure that the crash doesn't make you lose output. (It slows things down a bit, but there's nothing slower than a crash so who cares?)

fconfigure stdout -buffering none

You still might not get any helpful output (but probably will if you add lots of debugging puts calls to your callbacks) but at least the crash won't wipe out that which you otherwise would have.

Also note that stderr is always configured like that, precisely so that you can easily avoid losing output when things are crashing.