Skip to content

MuQuadNode: Remove reference to ophaned 'plain' node classes

Tom Williams requested to merge task/bug-avoid-referencing-orphan-node into main

@dinyar: I've updated MuQuadNode constructor as described in the title. This should resolve the problem you encountered earlier today in the SWATCH cell at Point 5:

28 Sep 2020 14:47:12.548 [140399378073344] ERROR trigger.cms.l1ts-ugmt.p:3333.ugmttscell::Cell.instance(21).CellOperationFactory.CellOperation <> - Caught exception when constructing system ...
   Config key: ugmt_base/v49
   Exception type: swatch::system::SystemConstructionFailed
   Message:  Failed to create/add Processor (id: 'ugmt_processor'). Caught exception 'std::bad_alloc', message: std::bad_alloc

Reason the change is required: In uHAL 'derived node' classes, the node reference included in the constructor's arguments points to a temporary object, and so shouldn't be used outside of the constructor; instead, 'derived node' classes should use *this.


Debugging results that lead me to believe this merge request should fix the problem:

  • After attaching to the SWATCH cell with gdb, creating a few breakpoints and reproducing the error, I found that the exception was thrown from inside the constructor of this derived node class. Callstack (ignoring all but only 10 innermost function calls):
#0  0x00007fb150cbd920 in __cxa_throw () from /lib64/libstdc++.so.6
#1  0x00007fb150cbdf2d in operator new(unsigned long) () from /lib64/libstdc++.so.6
#2  0x00007fb150d1ca19 in std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) () from /lib64/libstdc++.so.6
#3  0x00007fb150d1d62b in std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) () from /lib64/libstdc++.so.6
#4  0x00007fb150d1d6d4 in std::string::reserve(unsigned long) () from /lib64/libstdc++.so.6
#5  0x00007fb150d1d798 in std::string::append(std::string const&) () from /lib64/libstdc++.so.6
#6  0x00007fb0ef3b69cc in uhal::Node::getRelativePath(uhal::Node const&) const () from /opt/cactus/lib/libcactus_uhal_uhal.so.2.7
#7  0x00007fb0ef3ba657 in uhal::Node::getNodes(std::string const&) const () from /opt/cactus/lib/libcactus_uhal_uhal.so.2.7
#8  0x00007fb0f9359c24 in ugmt::MuLUTManagerNode::MuLUTManagerNode(uhal::Node const&, std::string const&) () from /opt/cactus/lib/libcactus_ugmt.so
#9  0x00007fb0f935f585 in ugmt::MuQuadNode::MuQuadNode(uhal::Node const&) () from /opt/cactus/lib/libcactus_ugmt.so
#10 0x00007fb0f9363351 in uhal::DerivedNodeFactory::Creator<ugmt::MuQuadNode>::create(uhal::Node const&) () from /opt/cactus/lib/libcactus_ugmt.so
  • Provided that /opt/cactus/lib and the path to this repository's library are included in LD_LIBRARY_PATH, a memory-related error is also reported when just parsing the uGMT address tables with the following command:
python -c "import ctypes; ctypes.cdll.LoadLibrary('libcactus_ugmt.so'); import uhal; uhal.getDevice('device', 'ipbusudp-2.0://localhost:50001', 'file://address_tables_v5_0_0/mp7xe_infra.xml')"

With the change from this merge request, the address table can be parsed without any problems.

Merge request reports