From: Erick Mattos <erick.mattos@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "Thomas Rast" <trast@student.ethz.ch>,
"Junio C Hamano" <gitster@pobox.com>,
git@vger.kernel.org, "Ævar Arnfjörð" <avarab@gmail.com>
Subject: Re: [PATCH next v2] log_ref_setup: don't return stack-allocated array
Date: Fri, 11 Jun 2010 15:54:41 -0300 [thread overview]
Message-ID: <AANLkTikhgl2b_66POXPf1nJSlhwkY5PV1Qce3cA9yXOx@mail.gmail.com> (raw)
In-Reply-To: <20100611051236.GA3947@coredump.intra.peff.net>
Hi,
2010/6/11 Jeff King <peff@peff.net>:
> No, Thomas is right. This invokes undefined behavior. We point the
> passed-in log_file pointer to the front of a character array with
> automatic duration. After log_ref_setup returns, we must never
> dereference that pointer again, but we do. So we need this patch or
> something like it.
You and Thomas are right on this subject. I don't know when and how I
could see a malloc() in git_(v)snpath(). My fault.
>> Then git_snpath() creates a char array in the heap with the right
>> content and changes the stack pointer logfile to it. Then when we do
>
> No, it doesn't. git_snpath writes into the buffer you provide it, just
> like snprintf (hence the name).
The source of my failure.
> We have some false positives in git, but you don't see them because
> t/valgrind/default.supp suppresses them. For example:
>
> http://thread.gmane.org/gmane.comp.version-control.git/106335/focus=107302
>
> If you are using a binary package of valgrind, it probably ships with
> some system-specific suppressions, too. Right now valgrind on Debian
> unstable is next to useless because glibc has been upgraded to 2.11, but
> the suppressions haven't been updated. So you get false positives all
> over the place because of clever architecture-specific optimizations
> (e.g., I am seeing a lot of __strlen_sse2 problems, which are probably
> just the function over-reading its input data because processing big
> chunks is faster).
>
> -Peff
Thanks for the extended explanation about valgrind.
Regards to all
next prev parent reply other threads:[~2010-06-11 18:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-10 12:43 [PATCH next] log_ref_setup: don't return stack-allocated array Thomas Rast
2010-06-10 12:54 ` [PATCH next v2] " Thomas Rast
2010-06-10 16:48 ` Erick Mattos
2010-06-10 17:29 ` Thomas Rast
2010-06-10 23:09 ` Erick Mattos
2010-06-11 5:12 ` Jeff King
2010-06-11 18:54 ` Erick Mattos [this message]
[not found] ` <AANLkTinI44rPfeXvWr-7jvAVyw5itX_gUsHimwSL74Lv@mail.gmail.com>
2010-06-10 18:09 ` Ævar Arnfjörð Bjarmason
2010-06-10 18:43 ` [PATCH] check_aliased_update: strcpy() instead of strcat() to copy Thomas Rast
2010-06-10 19:00 ` Ævar Arnfjörð Bjarmason
2010-06-10 19:26 ` Jay Soffian
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTikhgl2b_66POXPf1nJSlhwkY5PV1Qce3cA9yXOx@mail.gmail.com \
--to=erick.mattos@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=trast@student.ethz.ch \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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).