Bug 1117

Summary: bindings failures on selected platforms
Product: ns-3 Reporter: Tom Henderson <tomh>
Component: python bindingsAssignee: Gustavo J. A. M. Carneiro <gjcarneiro>
Severity: normal CC: jpelkey, ns-bugs
Priority: P5    
Version: pre-release   
Hardware: All   
OS: All   

Description Tom Henderson 2011-04-26 00:47:42 EDT
as can be observed on this buildbot:

there are problems with the internet bindings on some but not all systems.  While it shows up on gcc-3.4.6 and in general with gcc-3.4, it also is on Ubuntu karmic (gcc-4.4.1):

> CRASH: Example examples/routing/simple-routing-ping6.py
> PASS: Example examples/wireless/wifi-ap.py
> CRASH: Example examples/wireless/mixed-wireless.py
> PASS: Example examples/tutorial/first.py
> CRASH: Example src/bridge/examples/csma-bridge.py
> CRASH: Example src/flow-monitor/examples/wifi-olsr-flowmon.py

What the above all have in common is the use of internet (arp), and
specifically this is the error:

nsnam@ns-ubuntu-karmic:~/ns-3-allinone/ns-3-dev$ ./waf --pyrun
Waf: Entering directory `/home/nsnam/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/nsnam/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (1.718s)

Modules built:
core, network, config-store, internet, propagation, point-to-point, csma,
emu, bridge, tap-bridge, virtual-net-device, applications,
nix-vector-routing, olsr, aodv, dsdv, click, openflow, mobility, wifi,
netanim, stats, uan, spectrum, mesh, test, ns3tcp, ns3wifi, flow-monitor,
wimax, lte, mpi, topology-read, energy, tools, visualizer

examples/wireless/mixed-wireless.py:54: DeprecationWarning: the ns3 module
is a compatibility layer and should not be used in newly written code
 import ns3
Enabling OLSR routing on all backbone nodes
msg="Incompatible types. (feed to "c++filt -t" if needed)
got=ns3::MemPtrCallbackImpl<ns3::Ptr<ns3::ArpCache>, void
(ns3::ArpCache::*)(), void, ns3::empty, ns3::empty, ns3::empty, ns3::empty,
ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>
expected=ns3::CallbackImpl<void, ns3::empty, ns3::empty, ns3::empty,
ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty>*",
file=debug/ns3/callback.h, line=470
Command ['/usr/bin/python', 'examples/wireless/mixed-wireless.py']
terminated with signal SIGSEGV. Run it under a debugger to get more
information (./waf --run <program> --command-template="gdb --args %s

This is on Ubuntu Karmic (32-bit linux with gcc-4.4.1).
Comment 1 Gustavo J. A. M. Carneiro 2011-04-29 09:40:48 EDT
I'm pretty sure this is just another instance of cross-dll dynamic_cast failures.  I just tested this quick fix, and it solves the problem (tested in examples/routing/simple-routing-ping6.py), but of course it makes the python bindings less "modular": it forces all python modules to link to all ns-3 module libraries.

Since newer systems appear to have this dlopen/dynamic_cast issue fixed, I think the ideal way to fix this would be to add some waf configure compilation/runtime test, and depending on the test result make python modules link to all libraries or not.  But the waf (and C++ test) code to do this is not trivial.   As temporary fallback, I'm ok with just applying this simple patch, at least until I find time to develop the more complete bug fix...

diff -r f0748224dd68 src/wscript
--- a/src/wscript	Thu Apr 28 09:10:29 2011 -0700
+++ b/src/wscript	Fri Apr 29 09:34:50 2011 -0400
@@ -251,7 +251,7 @@ def ns3_python_bindings(bld):
     pymod.source = ['bindings/ns3module.cc']
     pymod.target = '%s/%s' % (module_target_dir, extension_name)
     pymod.name = 'ns3module_%s' % module
-    pymod.uselib_local = "ns3-"+module
+    pymod.uselib_local = pymod.env['NS3_ENABLED_MODULES']  #"ns3-"+module
     if pymod.env['ENABLE_STATIC_NS3']:
         if sys.platform == 'darwin':
             pymod.env.append_value('LINKFLAGS', '-Wl,-all_load')
Comment 2 Josh Pelkey 2011-04-29 11:47:43 EDT
Well I'd love to see green buildbots very soon, so if this is what it takes for now, I'm all for it.
Comment 3 Tom Henderson 2011-04-29 12:06:30 EDT
(In reply to comment #2)
> Well I'd love to see green buildbots very soon, so if this is what it takes for
> now, I'm all for it.

Please commit your workaround, and we can keep this open if you plan to improve it in the future (feel free to rename the bug title).
Comment 4 Gustavo J. A. M. Carneiro 2011-04-29 13:27:57 EDT
changeset:   7098:bb919b08a773
tag:         tip
user:        Gustavo J. A. M. Carneiro  <gjc@inescporto.pt>
date:        Fri Apr 29 18:27:03 2011 +0100
summary:     Link Python bindings modules to all enabled ns-3 module libraries.  Fixes #1117.