From a203cfaf203dc53f9e4d51988ff05371a22ecf9f Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 12 Aug 2015 02:31:41 +0200 Subject: [PATCH] investigation: Segfault in GDB (I) after upgrading my system to Debian/Jessie, I get a segfault in gdb, on attempt to launch the test-suite. By reducing the modules linked into the test-suite, I could narrow down the problematic code. It should be noted though, that this code is not the only problematic object, rather it is one of several ways to make gdb crash. I picked this example, as it is rather recent code and lookes fairly straight forward. Next step was to extract the first segment of the unit test and plant it into a simple executable with a main function and without any fancy loading of dynamic libraries. So it turns out that shared object loading is *not* involved. But some "interesting" new C++11 constructs are involved, like passing a local function-ref into a lambda, which later on will be wrapped into a Lumiera Iterator and then evaluated through a range-for-loop. Sounds interesting --- research/try.cpp | 132 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 93 insertions(+), 39 deletions(-) diff --git a/research/try.cpp b/research/try.cpp index 9f446bd07..7330f2263 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -27,71 +27,125 @@ // 7/14 - c++11 transition: std hash function vs. boost hash // 9/14 - variadic templates and perfect forwarding // 11/14 - pointer to member functions and name mangling +// 8/15 - Segfault when loading into GDB (on Debian/Jessie 64bit /** @file try.cpp - ** Investigation: member function pointers, types and name mangling. + ** Investigation: Segfault when loading into GDB (on Debian/Jessie 64bit) ** */ #include "lib/test/test-helper.hpp" #include "lib/util.hpp" +#include "lib/format-util.hpp" +#include "lib/diff/record.hpp" +#include "lib/itertools.hpp" +#include "lib/util.hpp" //////TODO necessary? -#include #include +//#include #include - -using lib::test::showType; -using lib::test::demangleCxx; +#include using std::string; +using util::isSameObject; +using util::isnil; +using std::vector; +//using std::swap; using std::cout; using std::endl; -class Interface - { - public: - virtual ~Interface() { } ///< this is an interface - - virtual string moo() =0; - virtual string boo() =0; - }; -class Impl - : public Interface - { - string s_; +namespace lib { +namespace diff{ +namespace test{ + +// using lumiera::error::LUMIERA_ERROR_LOGIC; + using lumiera::error::LUMIERA_ERROR_INVALID; + using lumiera::error::LUMIERA_ERROR_BOTTOM_VALUE; + + namespace {//Test fixture.... - string moo() { return s_ + " Moo"; } - string boo() { return s_ + " Boo"; } + using Seq = vector; + using RecS = Record; - public: - Impl(string ss ="IMP") - : s_(ss) - { } - }; + template + inline Seq + contents (IT const& it) + { + Seq collected; + append_all (it, collected); + return collected; + } + + inline Seq + contents (RecS const& rec_of_strings) + { + return contents (rec_of_strings.begin()); + } + + template + inline Seq + strings (std::initializer_list const& con) + { + Seq collected; + for (auto elm : con) + collected.push_back(elm); + return collected; + } + + + }//(End)Test fixture + + + + + + + + /*************************************************************************************//** + * @test Verify properties of a special collection type meant for external representation + * of object-like data. + * + * @see IndexTable + * @see DiffListApplication_test + */ + class GenericRecordRepresentation_test// : public Test + { + public: + virtual void + run () + { + simpleUsage(); + } + + + void + simpleUsage() + { + RecS enterprise("starship" + , strings ({"Name = USS Enterprise" + ,"Registry = NCC-1701-D" + ,"Class = Galaxy" + ,"Owner = United Federation of Planets" + ,"built=2363" + }) + , strings ({"Picard", "Riker", "Data", "Troi", "Worf", "Crusher", "La Forge"}) + ); + + cout << "enterprise = " << string(enterprise)<