Solaris on Sparc Bus Error

Matt Joss matt.joss at roguesheep.com
Thu Sep 11 15:19:34 PDT 2008


I ran into some problems running Exempi on a Solaris machine with a  
Sparc chip.  Running the 'dumpmainxmp' sample would cause a bus  
error.  The problem is with memory alignment.  The Sparc chip requires  
memory to be accessed on 32 bit boundaries for anything but single  
byte access and the XMP toolkit violates this causing a bus error.   
The particular place I noticed it is in the GetUns16BE() method in  
EndianUtils.hpp.  There it is casting a memory address to a XMP_Uns16  
and trying to dereference it.

I fixed it at this location, but ran into another bus error that I  
didn't feel like tracking down.  I did find a solution on the web.   
The solution is to install a misaligned trap handler to handle this  
scenario.  This can have a significant performance impact, but for my  
purposes this was not a problem.

To install misaligned trap handler, add the following call to your  
main() function...

asm("ta\t6");


i.e. main would look like ...

extern "C" int
main ( int argc, const char * argv [] )
{
	asm("ta\t6");

	// REST OF CODE HERE
}

This would be better fixed in the code, but barring that, this  
solution may allow you to use exempi on sparc.

Matt Joss


More information about the Exempi-devel mailing list