yaml-cpp icon indicating copy to clipboard operation
yaml-cpp copied to clipboard

Crash on arm32 with 0.6.3 (works with 0.5.2)

Open mjj29 opened this issue 3 years ago • 1 comments

Hi there, we recently upgraded from 0.5.2 to 0.6.3 and when testing this on our armhf (it's a raspberry PI 4), which also was upgraded from Jessie to Buster, we started getting a mixture of crashes, or failing to properly parse the YAML - which I suspect is just 'the undefined behaviour didn't crash this time'.

We do this:

YAML::Node yconfig = YAML::LoadFile(filename); if (!yconfig.IsMap()) { throw std::runtime_error(...); }

The failure is that it hits that throw, despite the file clearly containing a YAML map. If I try and add a print of yconfig.Scalar().c_str() between those lines, then it crashes in the std::string constructor.

When it crashes, the backtrace looks like:

Backtrace:
   signal SIGSEGV, Segmentation fault
   YAML::detail::node_data::type (this=0x0) at /users/ukcam/matj/svn/10.11.0.x/apama-lib5/all/yaml-cpp/0.6.3/include/yaml-cpp/node/detail/node_data.h:47 47         return m_isDefined ? m_type : NodeType::Undefined; [Current thread is 1 (Thread 0xb37da5e0 (LWP 12435))]
   YAML::detail::node_data::type (this=0x0) at /users/ukcam/matj/svn/10.11.0.x/apama-lib5/all/yaml-cpp/0.6.3/include/yaml-cpp/node/detail/node_data.h:47
   YAML::detail::node_ref::type (this=0x32801a8) at /users/ukcam/matj/svn/10.11.0.x/apama-lib5/all/yaml-cpp/0.6.3/include/yaml-cpp/node/detail/node_ref.h:25
   YAML::detail::node::type (this=0x3280188) at /users/ukcam/matj/svn/10.11.0.x/apama-lib5/all/yaml-cpp/0.6.3/include/yaml-cpp/node/detail/node.h:30
   YAML::Node::Type (this=0xbed1f1cc) at /users/ukcam/matj/svn/10.11.0.x/apama-lib5/all/yaml-cpp/0.6.3/include/yaml-cpp/node/impl.h:89
   YAML::Node::IsNull (this=0xbed1f1cc) at /users/ukcam/matj/svn/10.11.0.x/apama-lib5/all/yaml-cpp/0.6.3/include/yaml-cpp/node/node.h:56
   com::apama::YAMLParser::loadYamlFiles (this=0x15b5f48 <cConfig>, yamlFiles=std::vector of length 24, capacity 24, logger=...) at /users/ukcam/matj/svn/10.11.0.x/apama-src/cpp-common/file-util/src/YAMLParser.cpp:508

Looking in gdb at the resulting core we see:

#0  YAML::detail::node_data::type (this=0x0) at /users/ukcam/matj/svn/10.11.0.x/apama-lib5/all/yaml-cpp/0.6.3/include/yaml-cpp/node/detail/node_data.h:47
#1  0xb47ab8d8 in YAML::detail::node_ref::type (this=0x32801a8) at /users/ukcam/matj/svn/10.11.0.x/apama-lib5/all/yaml-cpp/0.6.3/include/yaml-cpp/node/detail/node_ref.h:25

So it's clearly looking at a null pointer somewhere. A little more gdb digging shows:

(gdb) p m_pData
$1 = <error reading variable: Cannot access memory at address 0x2d>
(up a frame)
(gdb) p *this
$4 = {m_pRef = std::shared_ptr<YAML::detail::node_ref> (expired, weak count 0) = {get() = 0x32801a8}, m_dependencies = std::set with 0 elements}

That expired weak pointer seems suspicious.

These are built with gcc 8.3.1 on RaspiOS 10.

I tried rebuilding 0.5.2 on the same platform, and this doesn't have these problems, so it looks like a regression introduced somewhere between the two (although I did have to patch it to work with boost 1.76, previously it was building with boost 1.63).

mjj29 avatar Aug 27 '21 16:08 mjj29

Hi, Could someone check this https://github.com/jbeder/yaml-cpp/issues/1023 issue?

ramanawithu avatar Sep 15 '21 12:09 ramanawithu