From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2797 invoked by alias); 25 May 2012 18:13:00 -0000 Received: (qmail 2783 invoked by uid 22791); 25 May 2012 18:12:57 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_RG X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 May 2012 18:12:42 +0000 From: "ja11sop at yahoo dot co.uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53490] New: Segmentation Fault when accessing std::set Date: Fri, 25 May 2012 18:13:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: blocker X-Bugzilla-Who: ja11sop at yahoo dot co.uk X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-05/txt/msg02502.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53490 Bug #: 53490 Summary: Segmentation Fault when accessing std::set Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: blocker Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: ja11sop@yahoo.co.uk The following g++ 4.7 compiled code, when executed on x86_64 Debian Sid, segfaults. The code is a reduced sample from a much larger code-base of production code that ran ok with gcc4.6. With more time I could reduce it further but this already consistently hits the problem and produces a useful back trace. I have this as a blocker because all our application code essentially executes something similar to this and so now all our applications segfault when built with gcc4.7. Also I cannot come up with a trivial work-around without re-writing large parts of the code base. CODE: //------------------------------------------------------------------ // Boost Library Includes #include #include #include #include // C++ Standard Library Includes #include #include typedef boost::property_tree::ptree property_tree_t; typedef boost::shared_ptr shared_property_tree_t; void store_properties( int argc, const char* argv[] ) { typedef boost::program_options::options_description options_description_t; typedef boost::program_options::variables_map variables_t; options_description_t Options( "Base Options" ); Options.add_options()( "help,h", "Display Help" ); variables_t Variables( new variables_t() ); boost::program_options::parsed_options ParsedOptions = parse_command_line( argc, argv, Options ); boost::program_options::store( ParsedOptions, Variables ); boost::program_options::notify( Variables ); } typedef std::string string_t; typedef std::set string_set_t; typedef boost::shared_ptr shared_string_set_t; shared_string_set_t get_unique_keys( const string_t& Key, const property_tree_t& PropertyTree ) { if( auto Children = PropertyTree.get_child_optional( Key ) ) { shared_string_set_t Values( new string_set_t() ); for( auto& Child : *Children ) { // This line is required for the segfault Values->insert( Child.first ); } return Values; } return shared_string_set_t(); } int main( int argc, char* argv[] ) { const char* DummyArgv[] = { "std_set_bug_test", "--help", 0 }; shared_property_tree_t PropertyTree = boost::make_shared(); store_properties( 2, DummyArgv ); // No need to call this code //auto UniqueKeys = get_unique_keys( "log.sink", *PropertyTree ); return 0; } //------------------------------------------------------------------ Code compiled with: -Wall -g -std=c++11 Linked *statically* with the boost 1.49 program_options library. BACKTRACE: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7933427 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (gdb) bt #0 0x00007ffff7933427 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #1 0x000000000046412d in std::_Rb_tree_iterator::operator-- (this=0x7fffffffdc60) at /usr/include/c++/4.7/bits/stl_tree.h:203 #2 0x0000000000462caa in std::pair, bool> std::_Rb_tree, std::less, std::allocator >::_M_insert_unique(std::string const&) () #3 0x0000000000461b25 in std::set, std::allocator >::insert(std::string const&) () #4 0x000000000047aeb1 in boost::program_options::store (options=..., xm=..., utf8=false) at libs/program_options/src/variables_map.cpp:98 #5 0x0000000000460350 in store_properties(int, char const**) () #6 0x00000000004606ab in main () (gdb)