public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
From: Gary Thomas <gary@mlbassoc.com>
To: Jose Vasconcellos <jvasco@verizon.net>
Cc: ecos-patches@ecos.sourceware.org
Subject: Re: redboot fconfig crash with gcc 4.3.2
Date: Tue, 20 Jan 2009 07:55:00 -0000	[thread overview]
Message-ID: <49758360.4020009@mlbassoc.com> (raw)
In-Reply-To: <4974FD62.9090602@verizon.net>

Jose Vasconcellos wrote:
> Redboot gets an exception when trying to set any IP address with fconfig
> when using gcc-4.3.2 on an ixp425 target (armeb). The issue seems to be
> an alignment problem as val_ptr contains an odd address; it looks like gcc
> is optimizing and trying to do a copy on a word boundary. The removal of
> the cast fixes the problem.
> 
> 
> --- fconfig.c    2009-01-18 14:34:11.000000000 -0500
> +++ fconfig.c.new    2009-01-18 14:35:22.000000000 -0500
> @@ -388,7 +388,7 @@
>        break;
> #ifdef CYGPKG_REDBOOT_NETWORKING
>    case CONFIG_IP:
> -        memcpy(&hold_ip_val.s_addr, &((in_addr_t *)val_ptr)->s_addr, 
> sizeof(in_addr_t));
> +        memcpy(&hold_ip_val.s_addr, val_ptr, sizeof(in_addr_t));
>        if (!_gethostbyname(line, &new_ip_val)) {
>            return CONFIG_BAD;
>        }
> 

Sounds like a *BUG* in the compiler.  Have you reported it?

This does more than remove the cast :-)  What if the s_addr field is not
at the start of the structure?  I know it hasn't moved in 25+ years, but
I don't like tossing correctness [even if only pedantic] away.

Maybe there's another way to solve this.  Does it happen on arm[el]?

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

  reply	other threads:[~2009-01-20  7:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-19 22:23 Jose Vasconcellos
2009-01-20  7:55 ` Gary Thomas [this message]
2009-01-20  9:20   ` Daniel Néri
2009-01-20 13:19   ` Jose Vasconcellos

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=49758360.4020009@mlbassoc.com \
    --to=gary@mlbassoc.com \
    --cc=ecos-patches@ecos.sourceware.org \
    --cc=jvasco@verizon.net \
    /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).