<div dir="ltr">Well, Jeff, I would really be happy _not_ to have managed to do this...<div>So you suggest on v7 it should actually be ok? do you have any reference I could inform myself a bit more?</div><div><br></div><div>thanks<br><br>On Wednesday, 23 October 2013 20:38:00 UTC+2, Jeffrey Walton wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">>> Yes, that's not legal C/C++. Its undefined behavior.
<br>>
<br>> how do you mean?
<br>> I get SIGBUS also for things like:
<br>> tempx = ( double* )ptr;
<br>Its not legal C/C++.
<br>
<br>> I run my code on ARMv7 after building with:
<br>That's interesting that you could induce that on an ARMv7. I was
<br>trying to do it for the longest time (for use as a test case, see
<br><a href="http://stackoverflow.com/questions/15233717/linux-x86-x64-turn-off-misaligned-data-fixups" target="_blank">http://stackoverflow.com/<wbr>questions/15233717/linux-x86-<wbr>x64-turn-off-misaligned-data-<wbr>fixups</a>).
<br>
<br>Jeff
<br>
<br>On Wed, Oct 23, 2013 at 2:00 PM, Marco Bernasocchi
<br><<a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8PrU0ZupTMJ">ma...@bernawebdesign.ch</a>> wrote:
<br>> On 10/23/2013 07:45 PM, Jeffrey Walton wrote:
<br>>>>
<br>>>> I often get SIGBUS when my code (<a href="http://qgis.org" target="_blank">qgis.org</a>) hits stuff like this:
<br>>>>
<br>>>> GEOSCoordSeq_getX( cs, j, ( double * )&mGeometry[position] );
<br>>>
<br>>> Yes, that's not legal C/C++. Its undefined behavior.
<br>>
<br>> how do you mean?
<br>> I get SIGBUS also for things like:
<br>> tempx = ( double* )ptr;
<br>>
<br>> and replacing with the following does the job:
<br>> memcpy( &tempx, ptr, sizeof( tempx ) );
<br>>
<br>>>
<br>>>> double a;
<br>>>> memcpy( a, &mGeometry[position])
<br>>>> GEOSCoordSeq_getX( cs, j, &a )
<br>>>>
<br>>>> then all works correctly,
<br>>>
<br>>> Yep. And if the buffers overlap, you need to `memmov` it.
<br>>>
<br>>>> could this be because of a
<br>>>> compiler setting?
<br>>>
<br>>> No, its the QT devs doing something they should not be doing. Newer
<br>>> ARMs are OK with unaligned data, while older ARMs are not. They appear
<br>>> to be testing on newer ARMs only (ARMv6 or ARMv7, IIRC).
<br>>
<br>> I run my code on ARMv7 after building with:
<br>> for debug:
<br>> CFLAGS: -DANDROID -Wno-psabi -std=c99 -g -O0 -marm -finline-limit=300
<br>> -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG -march=armv7-a
<br>> -mfloat-abi=softfp -mfpu=vfp
<br>> CXXFLAGS: -DANDROID -Wno-psabi -std=gnu++0x -g -O0 -marm -finline-limit=300
<br>> -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG
<br>> LDFLAGS: -Wl,--fix-cortex-a8
<br>>
<br>> for release:
<br>> CFLAGS: -DANDROID -Wno-psabi -std=c99 -mthumb -O0 -march=armv7-a
<br>> -mfloat-abi=softfp -mfpu=vfp
<br>> CXXFLAGS:-DANDROID -Wno-psabi -std=gnu++0x -mthumb -O0 -march=armv7-a
<br>> -mfloat-abi=softfp -mfpu=vfp
<br>> LDFLAGS: -Wl,--fix-cortex-a8
<br>>
<br>>
<br>>>
<br>>> I believe -Wstrict-aliasing or -Wcast-align will catch it at compile
<br>>> time. See <a href="http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html" target="_blank">http://gcc.gnu.org/onlinedocs/<wbr>gcc/Warning-Options.html</a> and
<br>>>
<br>>> <a href="https://www.gnu.org/software/gsl/manual/html_node/GCC-warning-options-for-numerical-programs.html#GCC-warning-options-for-numerical-programs" target="_blank">https://www.gnu.org/software/<wbr>gsl/manual/html_node/GCC-<wbr>warning-options-for-numerical-<wbr>programs.html#GCC-warning-<wbr>options-for-numerical-programs</a><wbr>.
<br>>>
<br>> thanks a lot
<br>>>
<br>>> Jeff
<br>>>
<br>>> On Wed, Oct 23, 2013 at 1:12 PM, Marco Bernasocchi
<br>>> <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="x8PrU0ZupTMJ">ma...@bernawebdesign.ch</a>> wrote:
<br>>>>
<br>>>> Hi all, I often get SIGBUS when my code (<a href="http://qgis.org" target="_blank">qgis.org</a>) hits stuff like this:
<br>>>>
<br>>>> GEOSCoordSeq_getX( cs, j, ( double * )&mGeometry[position] );
<br>>>>
<br>>>> if I change the call to use memcpy like
<br>>>>
<br>>>> double a;
<br>>>> memcpy( a, &mGeometry[position])
<br>>>> GEOSCoordSeq_getX( cs, j, &a )
<br>>>>
<br>>>> then all works correctly, the issue is that I've a lot of those calls and
<br>>>> If
<br>>>> I'm not wrong in the past it used to work). could this be because of a
<br>>>> compiler setting? I'm using necessitas Qt sdk with ndk r8b1 compiling
<br>>>> both
<br>>>> with -mthumb and without has the same issue.
<br></blockquote></div></div>