Bug 274858 - Option to warn on unaligned memory access.
Summary: Option to warn on unaligned memory access.
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR wishlist
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-03 19:14 UTC by David Mathog
Modified: 2011-06-03 19:14 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Mathog 2011-06-03 19:14:35 UTC
It would be great if Valgrind could warn on unaligned memory access.  

These are not fatal on x86, but most likely cause a performance hit, whereas on Sparc they blow up code.  For instance, one of my programs used

#define ESP_INT(A,B) (*(int *)  &(A->string[B])) 

to pull an integer at offset B out of character array A->string.  Care was taken that all integers were stored aligned, but due to a small bug (an int stored as a string instead of as data, so a \0 was appened) one integer started at byte 9 instead of 8.  This was completely invisible on the Opteron where I was testing, but when the code ran on a Sparc it resulted in a segfault.

It would be wonderful to be able to catch these errors with valgrind.