EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: osiSockDiscoverBroadcastAddresses(): pointer not word-aligned?
From: Eric Norum <[email protected]>
To: Ralph Lange <[email protected]>
Cc: Jeff Hill <[email protected]>, EPICS Core Talk <[email protected]>, Ralf Hartmann <[email protected]>
Date: Tue, 22 Aug 2006 10:19:15 -0500
On Aug 22, 2006, at 9:41 AM, Ralph Lange wrote:

Hi Jeff, hi Eric,

a colleage of mine is trying to get EPICS running on RTEMS running on an ARM v4t.

The system crashes with a alignment fault in in BSD network stack function in_control() which gets a struct ifreq pointer. This pointer is created in osiSockDiscoverBroadcastAddresses(), where you create an array of such structures by calloc()ing 100 times the size of an struct ifreq (line 87).
Then you step through the array. When you call socket_ioctl() to get the broadcast address (line 177), that call causes the crash down in the BSD stack, because at that point the pointer pifreq is not word-aligned.

We think that somehow within the array the single struct ifreq entries are not word-aligned - which sounds not very likely looking at the ifreq definition, or that your stepping algorithm in ifreqNext() (line 38 ff.) returns a wrong address which is odd.

Any ideas?

What was the reason for using the ifreqNext() function instead of just stepping with sizeof (struct ifreq)?

The folks that wrote the original socket code didn't think about the possibility of really big addresses.  Nowadays it is possible for ifreqNext to have a stride greater than sizeof(struct ifreq).   The code in osdNetIntf.c has to deal with this.   As the comment in src/libCom/os/default/osdNetIntf.c says:
/*
* Move to the next ifreq structure
* Made difficult by the fact that addresses larger than the structure
* size may be returned from the kernel.
*/

To illustrate this, I added the following line to ifreqNext:
printf("ifreq_size (pifreq):%d    sizeof (*pifreq):%d\n", ifreq_size (pifreq), sizeof (*pifreq));

On OS X I get:
ifreq_size (pifreq):36    sizeof (*pifreq):32
ifreq_size (pifreq):32    sizeof (*pifreq):32
ifreq_size (pifreq):44    sizeof (*pifreq):32
ifreq_size (pifreq):44    sizeof (*pifreq):32
ifreq_size (pifreq):36    sizeof (*pifreq):32
ifreq_size (pifreq):36    sizeof (*pifreq):32
ifreq_size (pifreq):36    sizeof (*pifreq):32
ifreq_size (pifreq):44    sizeof (*pifreq):32
ifreq_size (pifreq):32    sizeof (*pifreq):32
ifreq_size (pifreq):36    sizeof (*pifreq):32
ifreq_size (pifreq):36    sizeof (*pifreq):32
ifreq_size (pifreq):36    sizeof (*pifreq):32



Now, getting back to your problem -- check to see what ifreq_size is returning on that machine.  Could be that you've uncovered a problem between the RTEMS (BSD) network stack and GCC for the ARM. 
-- 
Eric Norum <[email protected]>
Advanced Photon Source
Argonne National Laboratory
(630) 252-4793



Replies:
Re: osiSockDiscoverBroadcastAddresses(): pointer not word-aligned? Ralph Lange
References:
osiSockDiscoverBroadcastAddresses(): pointer not word-aligned? Ralph Lange

Navigate by Date:
Prev: osiSockDiscoverBroadcastAddresses(): pointer not word-aligned? Ralph Lange
Next: Re: osiSockDiscoverBroadcastAddresses(): pointer not word-aligned? Andrew Johnson
Index: 2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: osiSockDiscoverBroadcastAddresses(): pointer not word-aligned? Ralph Lange
Next: Re: osiSockDiscoverBroadcastAddresses(): pointer not word-aligned? Ralph Lange
Index: 2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·