From 4548bd1a650ea302bfa04fe4fa28be97c261a106 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Fri, 5 Jun 2015 13:50:14 +0200 Subject: [PATCH] cql_test_env: Work-around infinite recursion in boost::any cql_query_test segfaults in debug mode due to infinite recursion (see trace below). The problem started to appear after Avi's always-defer change. It looks like the following boost::any() constructor template is instantiated when boost::any is copied into a lambda: // Perfect forwarding of ValueType template any(ValueType&& value, typename boost::disable_if >::type* = 0) : content(new holder< typename remove_reference::type >(static_cast(value))) { } It checks for any& to disable itself on forwarding, but it doesn't check for const any&. There are (non-template) constructors which take const any&, but I guess some C++ rule favors the template version. This results in infinite recursion of constructor invocations between any() and holder(). Workaround is to make the lambda mutable, so that the argument type is any& and template doesn't kick in. Trace: CU 0x4debed5, DIE 0x4f176e6>, this=0x602000044550) at /usr/include/boost/any.hpp:175 ql_query_test, CU 0x4debed5, DIE 0x4f6c509>, this=0x602000044518) at /usr/include/boost/any.hpp:72 CU 0x4debed5, DIE 0x4f176e6>, this=0x602000044510) at /usr/include/boost/any.hpp:175 ql_query_test, CU 0x4debed5, DIE 0x4f6c509>, this=0x6020000444e8) at /usr/include/boost/any.hpp:72 CU 0x4debed5, DIE 0x4f176e6>, this=0x6020000444e0) at /usr/include/boost/any.hpp:175 oost::any const>, void>::type*) (this=0x7ffff2ffa6f0, value=) at /usr/include/boost/any.hpp:72 5u> const&, std::vector >, std::vector >, basic_sstring const&, boost::any)::{lambda(database&)#1}::operator()(data base&) const::{lambda(std::unique_ptr >)#1} ::unique_ptr(std::unique_ptr >&&) (this=0x7 ffff2ffa6c0) at tests/urchin/cql_test_env.cc:126 --- tests/urchin/cql_test_env.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/urchin/cql_test_env.cc b/tests/urchin/cql_test_env.cc index ca754820ed..10de724ef9 100644 --- a/tests/urchin/cql_test_env.cc +++ b/tests/urchin/cql_test_env.cc @@ -120,7 +120,7 @@ public: ks_name = std::move(ks_name), column_name = std::move(column_name), expected = std::move(expected), - table_name = std::move(table_name)] (database& db) { + table_name = std::move(table_name)] (database& db) mutable { auto& cf = db.find_column_family(ks_name, table_name); auto schema = cf.schema(); return cf.find_partition_slow(pkey).then([schema, ck, column_name, expected] (column_family::const_mutation_partition_ptr p) {