|
Bugzilla – Full Text Bug Listing |
| Summary: | no way to perform a helper container deep copy | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Mathieu Lacage <mathieu.lacage> |
| Component: | python bindings | Assignee: | ns-bugs <ns-bugs> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | gjcarneiro |
| Priority: | P3 | ||
| Version: | pre-release | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
patch
patch v2 |
||
|
Description
Mathieu Lacage
2008-08-18 15:48:45 UTC
I should point out that I tried this:
import copy
mobileAdhocNodes.Create (adhocCount - 1)
adhocNodes = copy.copy (mobileAdhocNodes)
adhocNodes.Add (gateway)
and get a segfault:
#0 0x00002acd183e82d2 in std::vector<ns3::Ptr<ns3::Node>, std::allocator<ns3::Ptr<ns3::Node> > >::push_back (this=0x0,
__x=@0x7fff940bbd80) at /usr/include/c++/4.1.3/bits/stl_vector.h:604
#1 0x00002acd18622651 in ns3::NodeContainer::Add (this=0x0, node=@0x7fff940bbd80) at ../src/helper/node-container.cc:93
#2 0x00002acd17a2aae7 in _wrap_PyNs3NodeContainer_Add__1 (self=0xd1b3f0, args=0x881f10, kwargs=0x0,
return_exception=0x7fff940bbde8) at debug/bindings/python/ns3_module_helper.cc:1678
#3 0x00002acd17a2ad5d in _wrap_PyNs3NodeContainer_Add (self=0xd1b3f0, args=0x881f10, kwargs=0x0)
at debug/bindings/python/ns3_module_helper.cc:1693
#4 0x0000000000488af7 in PyEval_EvalFrameEx ()
#5 0x0000000000488c3e in PyEval_EvalFrameEx ()
#6 0x0000000000489d60 in PyEval_EvalCodeEx ()
#7 0x0000000000489da2 in PyEval_EvalCode ()
#8 0x00000000004ab4fe in PyRun_FileExFlags ()
#9 0x00000000004ab790 in PyRun_SimpleFileExFlags ()
#10 0x0000000000414725 in Py_Main ()
#11 0x00002acd174c9b44 in __libc_start_main () from /lib/libc.so.6
#12 0x0000000000413c69 in _start ()
(gdb)
I ended up doing this:
mobileAdhocNodes.Create (adhocCount - 1)
adhocNodes = NodeContainer ()
adhocNodes.Add (mobileAdhocNodes)
adhocNodes.Add (gateway)
This is clearly an upstream pybindgen bug. Can you please file generic pybindgen bugs where they belong? -> https://bugs.launchpad.net/pybindgen/+bug/259215 I have a fix in pybindgen, but unfortunately ns-3 headers are too weird even for pybindgen: debug/ns3/ptr.h: In destructor ‘ns3::Ptr<T>::~Ptr() [with T = ns3::DcaTxop]’: debug/ns3/nqap-wifi-mac.h:54: instantiated from here debug/ns3/ptr.h:407: error: invalid use of incomplete type ‘struct ns3::DcaTxop’ debug/ns3/adhoc-wifi-mac.h:30: error: forward declaration of ‘struct ns3::DcaTxop’ debug/ns3/ptr.h: In destructor ‘ns3::Ptr<T>::~Ptr() [with T = ns3::MacLow]’: debug/ns3/nqap-wifi-mac.h:54: instantiated from here debug/ns3/ptr.h:407: error: invalid use of incomplete type ‘struct ns3::MacLow’ debug/ns3/adhoc-wifi-mac.h:35: error: forward declaration of ‘struct ns3::MacLow’ debug/ns3/ptr.h: In member function ‘void ns3::Ptr<T>::Acquire() const [with T = ns3::DcaTxop]’: debug/ns3/ptr.h:392: instantiated from ‘ns3::Ptr<T>::Ptr(const ns3::Ptr<T>&) [with T = ns3::DcaTxop]’ debug/ns3/nqap-wifi-mac.h:54: instantiated from here debug/ns3/ptr.h:362: error: invalid use of incomplete type ‘struct ns3::DcaTxop’ debug/ns3/adhoc-wifi-mac.h:30: error: forward declaration of ‘struct ns3::DcaTxop’ The reason is that default copy constructors are reported by gccxml for these classes, and so pybindgen generates code to use them. However, the incomplete types are killing the build. Created attachment 230 [details]
patch
This patch makes the problematic copy constructors private, thereby preventing pybindgen from using them. OK to commit?
1) If the copy constructors are used, their implementation is not valid 2) If the copy constructors are not used, there is no need to provide an implementation. Just declare them private. Finally, don't add a new private section to the class declaration: use the one at the bottom of the class and add the constructors at the end. Created attachment 231 [details]
patch v2
How about now?
looks good to me. Committed patch. Bug fixed. Now we can copy objects in two different ways: 1. newobj = Class(oldobj) 2. newobj = copy.copy(oldobj) |