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
This commit is contained in:
parent
7a9a378a4b
commit
a203cfaf20
1 changed files with 93 additions and 39 deletions
132
research/try.cpp
132
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 <cstddef>
|
||||
#include <iostream>
|
||||
//#include <utility>
|
||||
#include <string>
|
||||
|
||||
using lib::test::showType;
|
||||
using lib::test::demangleCxx;
|
||||
#include <vector>
|
||||
|
||||
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<string>;
|
||||
using RecS = Record<string>;
|
||||
|
||||
public:
|
||||
Impl(string ss ="IMP")
|
||||
: s_(ss)
|
||||
{ }
|
||||
};
|
||||
template<class IT>
|
||||
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<class X>
|
||||
inline Seq
|
||||
strings (std::initializer_list<X> 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)<<endl;
|
||||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int, char**)
|
||||
{
|
||||
Impl obj;
|
||||
Interface& ref = obj;
|
||||
|
||||
typedef string (Interface::*Memfun) (void);
|
||||
|
||||
|
||||
cout << "before call. Address... "<<&ref<<"\n";
|
||||
|
||||
cout << ref.moo() << endl;
|
||||
cout << ref.boo() << endl;
|
||||
|
||||
Memfun memfun = &Interface::moo;
|
||||
cout << demangleCxx (showType (memfun)) << endl;
|
||||
cout << demangleCxx (showType(&Interface::moo)) << endl;
|
||||
cout << (ref.*memfun) () << endl;
|
||||
lib::diff::test::GenericRecordRepresentation_test mist;
|
||||
mist.run();
|
||||
|
||||
cout << "\n.gulp.\n";
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue