git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Duy Nguyen <pclouds@gmail.com>,
	Christian Couder <christian.couder@gmail.com>
Subject: Re: [PATCH 0/2] compiling with -fsanitize=undefined
Date: Tue, 29 Dec 2015 01:44:35 -0500	[thread overview]
Message-ID: <20151229064435.GA31944@sigill.intra.peff.net> (raw)
In-Reply-To: <20151229063449.GA28755@sigill.intra.peff.net>

On Tue, Dec 29, 2015 at 01:34:49AM -0500, Jeff King wrote:

>   2. We have some unaligned memory accesses that presumably work OK on
>      x86, but would blow up on ARM or other platforms (I didn't test).
> 
> The latter looks like it's in the untracked cache code (Duy and
> Christian cc'd). Running t7063 gets me this:
> 
> dir.c:2631:45: runtime error: member access within misaligned address 0x7f19806ff185 for type 'const struct ondisk_untracked_cache', which requires 4 byte alignment
> 0x7f19806ff185: note: pointer points here
>  31 33 29 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00
>              ^

I took a brief look at fixing this, and it may actually be a false
positive, as well (in a manner of speaking; if the compiler thinks it is
undefined behavior, it may still be worth fixing so we don't fall prey
to some optimizations-gone-wild).

The line in question is:

  load_sha1_stat(&uc->ss_info_exclude, &ouc->info_exclude_stat,
		 ouc->info_exclude_sha1);

where "ouc" is the on-disk data cast to a struct. So we definitely
generate an unaligned pointer, but then we only access its contents via
get_be32(), which handles alignment. So it might actually be OK. I
dunno.

-Peff

      parent reply	other threads:[~2015-12-29  6:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-29  6:34 [PATCH 0/2] compiling with -fsanitize=undefined Jeff King
2015-12-29  6:35 ` [PATCH 1/2] avoid shifting signed integers 31 bits Jeff King
2015-12-30  0:09   ` Junio C Hamano
2015-12-30  4:25     ` Jeff King
2015-12-31  5:10   ` Duy Nguyen
2015-12-31  5:20     ` Jeff King
2016-01-04 17:52       ` Junio C Hamano
2016-01-04 23:32         ` Jeff King
2015-12-29  6:36 ` [PATCH 2/2] bswap: add NO_UNALIGNED_LOADS define Jeff King
2015-12-29  6:42   ` Eric Sunshine
2015-12-29  6:45     ` Jeff King
2015-12-29  6:44 ` Jeff King [this message]

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=20151229064435.GA31944@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@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 NNTP newsgroup(s).