From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6076 invoked by alias); 3 Oct 2014 10:09:05 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 6067 invoked by uid 89); 3 Oct 2014 10:09:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f173.google.com Received: from mail-lb0-f173.google.com (HELO mail-lb0-f173.google.com) (209.85.217.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 03 Oct 2014 10:09:03 +0000 Received: by mail-lb0-f173.google.com with SMTP id 10so722795lbg.32 for ; Fri, 03 Oct 2014 03:08:59 -0700 (PDT) X-Received: by 10.152.198.204 with SMTP id je12mr4893232lac.52.1412330939726; Fri, 03 Oct 2014 03:08:59 -0700 (PDT) Received: from [130.233.179.5] ([130.233.179.5]) by mx.google.com with ESMTPSA id iq1sm2534743lac.9.2014.10.03.03.08.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Oct 2014 03:08:58 -0700 (PDT) Message-ID: <542E75B9.9010504@gmail.com> Date: Fri, 03 Oct 2014 10:09:00 -0000 From: =?UTF-8?B?SGVucmlrIE1hbm5lcnN0csO2bQ==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: Jonathan Wakely CC: gcc-help Subject: Re: std::string clobbers memory when compiling without optimizations References: <542E5BF1.2070508@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00014.txt.bz2 Hi, On 10/03/2014 12:58 PM, Jonathan Wakely wrote: > Have you tried valgrind? Or compiling with GCC's -fstack-protector > option? I can't reproduce the problem, and I think it's pretty > unlikely std::string has that kind of bug without someone noticing > years ago. I'm not assuming that std::string has a bug (even though the title might suggest that), I'm just saying that the gdb watchpoint is triggered inside that function. I tried valgrind memcheck, but I'm no expert, so suggestions are welcome. Below is the output with stack-protector, what do you make out of it? Could it be my installation? - Henrik $ g++-4.9 -std=gnu++1y mvu.cc -o mvu $ ./mvu Correct diagonal: 1 1 1 Eigen::Matrix Incorrect diagonal: 1.81749e-316 1 1 $ g++-4.9 -std=gnu++1y -fstack-protector-all mvu.cc -o mvu $ ./mvu Correct diagonal: 1 1 1 Eigen::Matrix Incorrect diagonal: 1 2 3 $ g++-4.9 -std=gnu++1y -O1 -fstack-protector-all mvu.cc -o mvu $ ./mvu Correct diagonal: 1 1 1 Eigen::Matrix Incorrect diagonal: 1 1 1 g++-4.9 (Ubuntu 4.9.1-3ubuntu2~14.04.1) 4.9.1 Copyright (C) 2014 Free Software Foundation, Inc.