This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/8464: Bus Error (SIGBUS) due to misaligned access
- From: kyle_s_hoyt at raytheon dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 5 Nov 2002 16:17:56 -0000
- Subject: c++/8464: Bus Error (SIGBUS) due to misaligned access
- Reply-to: kyle_s_hoyt at raytheon dot com
>Number: 8464
>Category: c++
>Synopsis: Bus Error (SIGBUS) due to misaligned access
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Tue Nov 05 08:26:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Kyle Hoyt
>Release: 2.95.2 19991024
>Organization:
>Environment:
SunOS 2.6 Generic_108528-06 sun4u sparc SUNW,Ultra-250
>Description:
Copying of data from a pointer results in a SIGBUS error.
Basically, the compiler is generating a ldd instruction
when the data is not guaranteed to be 8-byte aligned.
I have tried to multiple options such as the __attribute__
((aligned)); but I can not get the compiler not to
create the ldd instruction.
>How-To-Repeat:
Compile the included code and run. Basically, this is
a real stripped down version of the program. The program
receives Navigation Data messages via a data tape. The
message is guarranteed to be 4 byte aligned but not 8 byte.
The ProcessNav routine stores a history of the navigation
data. Thus it copies the message and puts it in a FIFO.
The code works on Pentium (G++ complier) and PowerPC
(GreenHills compiler) platforms but not on Sparc.
>Fix:
Change the code to use bcopy.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="gccbug.txt"
Content-Disposition: inline; filename="gccbug.txt"
typedef struct
{
int message;
int numwords;
double latitude;
double longitude;
double altitude;
double ew_rate;
double ns_rate;
int time;
} NAVIGATION_DATAS __attribute__ ((aligned(4)));
void ProcessNavData(NAVIGATION_DATAS *nav_ptr)
{
NAVIGATION_DATAS store;
store = *nav_ptr;
}
int main()
{
unsigned int data[1024];
ProcessNavData((NAVIGATION_DATAS *)&data[0]);
ProcessNavData((NAVIGATION_DATAS *)&data[1]);
}