"Data misaligning" exception in memset32() on ARM

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
rvl2
Posts: 6
Joined: Sun Aug 23, 2009 10:43 am

"Data misaligning" exception in memset32() on ARM

Post by rvl2 »

I've got the exception with burning video driver on WM5 simulator (real device terminates the program silently).
Some background info about the problem http://blogs.msdn.com/grantri/archive/2 ... 83524.aspx

When backbuffer is of 16-bit format (true for WinCE) the destination pointer transferred to memset32() function can be not aligned to 4-byte boundary.

Code to reproduce the bug:

Code: Select all

#include <irrlicht.h>
#include <iostream>
#include <windows.h>
#include <string.h>

using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;


int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
{
	
	video::E_DRIVER_TYPE driverType = EDT_BURNINGSVIDEO;

	// create device and exit if creation failed

	IrrlichtDevice * device = createDevice(driverType, core::dimension2d<u32>(240, 320));

	if (device == 0)
		return 1; // could not create selected driver.

	video::IVideoDriver* driver = device->getVideoDriver();

	while(device->run() && driver)
	if (device->isWindowActive())
	{
		driver->beginScene(true, true, SColor(0,200,200,200));
		
		driver->draw2DRectangle(SColor(255, 0, 255, 0), rect<s32>(1,1,40,40));//<-exception
	
		driver->endScene();
	}

	device->drop();

	return 0;
}
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Re: "Data misaligning" exception in memset32() on

Post by vitek »

rvl2 wrote:When backbuffer is of 16-bit format (true for WinCE) the destination pointer transferred to memset32() function can be not aligned to 4-byte boundary.
I'm not sure I understand what you're saying. Are you saying that the backbuffer pointer passed to memset32() does not point to an address with 32-bit alignment?

It might be helpful if you showed which call to memset32() we are talking about here. There are only a few, but it will make it easier for the devs to deal with the problem if they don't have to install an emulator to find it.

Travis
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Actually, I don't think it really matters much. Several of the calls are suspect, but I think the one in executeBlit_Color_16_to_16() is the problem. It seems that there should be a memset16() for this purpose.

If someone is going to take the time to fix this, it might be a good idea to check the other call sites and determine if it would be safer and more appropriate to call memset() instead, noting that memset32() is not the same as memset(). It might also make sense to add an assertion to verify that the input pointer to memset32() is indeed 32-bit aligned so that alignment errors will show up regardless of architecture.

Travis
Post Reply