public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Boley <npboley@gmail.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: Paolo Bonzini <bonzini@gnu.org>, Michael Matz <matz@suse.de>,
	Ian Lance Taylor <iant@google.com>,
	gcc@gcc.gnu.org
Subject: Re: Possible Bug
Date: Tue, 29 Mar 2011 16:03:00 -0000	[thread overview]
Message-ID: <AANLkTik1Daaihq1ORDR4HHrNGakC1ErdvbGR6EEwC5bQ@mail.gmail.com> (raw)
In-Reply-To: <AANLkTimfYCWcQ-QfU3R66E8ptbJnzKyu3_O-CayGiO7U@mail.gmail.com>

>>> As some digging shows, already GCC 1.35 had effectively the same code.
>>> As soon as parameters are passed in registers GCC loads the parts fitting
>>> into registers as full words.  We could simply sorry() for these cases, as
>>> they never worked correctly.  Though I suppose that's quite unforgiving,
>>> as most of the time (struct in question not passing page border) it works
>>> fine.
>>
>> We should warn, I think.
>
> We should fix the bug ;)

Agreed ;-)

FWIW, this was particularly nasty because it was serious ( the
segfault lost more than a days work on a couple of occasions ) and it
was very very difficult to track down due to the fact that:

1) the read rarely crosses the page boundary. ( as others have noted )
2) seemingly trivial changes to the struct that didn't change the
alignment or the size would "fix" it
3) storing the data to an intermediate variable would "fix" it

Also, for some context, in my real application I am using packed
arrays of these ( so aligning each to the word boundary would be
pretty worthless ) and the bitfield is still 6 bytes but quite a bit
more complex ( copied below ).

Thank you all very much for the comments and the feedback. I am sorry
that my original report couldn't be more definitive.

Best,
Nathan Boley

#define CHR_BITS 15
#define LOCATION_BITS 28
#define MAX_NUM_SNPS 3
typedef struct __attribute__((__packed__))
{
    /* 1 if it covers at least 1 snp */
    unsigned covers_snp     :1;
    unsigned snp_coverage   :MAX_NUM_SNPS;

    /* read_type 0 = normal, 1 = junction */
    unsigned read_type      :1;

    /* the chr that the read came from */
    unsigned chr            :CHR_BITS;

    /*
     * Start of the sequence in the 5' direction -
     * so a read of length L that maps here covers
     * bps (loc, loc+1, ..., loc+L-1)
     */
    unsigned loc            :LOCATION_BITS;

} GENOME_LOC_TYPE;

  reply	other threads:[~2011-03-29 14:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-26 20:28 Nathan Boley
2011-03-27  7:38 ` Ian Lance Taylor
2011-03-28 11:06   ` Paolo Bonzini
2011-03-28 11:28     ` Richard Guenther
2011-03-28 11:47       ` Paolo Bonzini
2011-03-28 12:14         ` Richard Guenther
2011-03-28 13:37         ` Michael Matz
2011-03-28 13:54           ` Paolo Bonzini
2011-03-28 14:37             ` Richard Guenther
2011-03-29 16:03               ` Nathan Boley [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-01-31  0:33 possible bug Andrew Morton
2003-01-31  0:36 ` Jan Hubicka
2003-01-31  0:56   ` Andrew Morton
2003-01-31  8:08   ` Alexandre Oliva
2003-01-31 10:48     ` Fergus Henderson
1999-07-25 17:52 Manush Dodunekov
1999-07-26 10:57 ` Alexandre Oliva
1999-07-27  3:27   ` Manush Dodunekov
1999-07-27  3:37     ` Alexandre Oliva
1999-07-31 23:33       ` Alexandre Oliva
1999-07-31 23:33     ` Manush Dodunekov
1999-07-31 23:33   ` Alexandre Oliva
1999-07-31 23:33 ` Manush Dodunekov
1997-12-12 15:46 Possible Bug Mike Sullivan

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=AANLkTik1Daaihq1ORDR4HHrNGakC1ErdvbGR6EEwC5bQ@mail.gmail.com \
    --to=npboley@gmail.com \
    --cc=bonzini@gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=matz@suse.de \
    --cc=richard.guenther@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).