From: "Henrik Mannerström" <henrik.mannerstrom@gmail.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: std::string clobbers memory when compiling without optimizations
Date: Fri, 03 Oct 2014 10:09:00 -0000 [thread overview]
Message-ID: <542E75B9.9010504@gmail.com> (raw)
In-Reply-To: <CAH6eHdS_TJdXkp55r8P13q_9ScThVu8LG9mp-5PPqBimb2P90Q@mail.gmail.com>
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<double, 1, 3, 1, 1, 3>
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<double, 1, 3, 1, 1, 3>
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<double, 1, 3, 1, 1, 3>
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.
next prev parent reply other threads:[~2014-10-03 10:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-03 8:19 Henrik Mannerström
2014-10-03 9:58 ` Jonathan Wakely
2014-10-03 10:09 ` Henrik Mannerström [this message]
2014-10-03 10:20 ` Jonathan Wakely
2014-10-03 10:31 ` Henrik Mannerström
2014-10-03 12:36 ` Jonathan Wakely
2014-10-03 10:31 ` Marc Glisse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=542E75B9.9010504@gmail.com \
--to=henrik.mannerstrom@gmail.com \
--cc=gcc-help@gcc.gnu.org \
--cc=jwakely.gcc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).