SIGBUS on ( double * )

Marco Bernasocchi marco at bernawebdesign.ch
Thu Oct 24 18:10:47 UTC 2013


Well, Jeff, I would really be happy _not_ to have managed to do this...
So you suggest on v7 it should actually be ok? do you have any reference I 
could inform myself a bit more?

thanks

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


More information about the Necessitas-devel mailing list