[AD] Bug in MMX linear_clear_to_color8 with asynchronous usage

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hello,

I've been bothered by a bug in my program since months and was finally
able to track it down to some ALLEGRO code.
I'm unsure of the exact details, and it may even be my fault, but I will
try to explain it the best I can.

The bug I had was that sound in my program (not using Allegro sound
functionnalities) was sometimes stopping for no apparent reason after
loading a save-state. I eventually found that a certain variable was
getting screwed, but did not understand why.

One could think at first that it must be some generic programming
errors (screwing with memory, causing havoc with malloc, etc...) but I
finally found out the cause to be the MMX version of clear_to_color()!

I'm unsure of the details, but:
 - my sound code runs in a timer interrupt handler
 - the variable that gets screwed when manipulating is a 'float'
 - it only happens when I call clear_to_color()
   (my sound handler interrupt it asynchronously)
 - it does not if I disable the CPU_MMX bit from 'cpu_capabilities'.

I know that FPU registers are shared with MMX ones so I thought that
maybe the clear_to_color() code doesn't handle/save/use MMX registers
well and if an asynchronous event happen, sometimes get screwed.

I suppose that the system & compiler does a correct job at handling
switches before and after an interruption, so I did nothing special
(my timer callback function is a simple C function).

I'm using:
	Windows 98
	DJGPP / GCC 3.1
	Allegro 4.1.19 (just upgraded today from 4.0.1 to test)

I'm not very familiar with MMX code so I can't help more than that
for the moment, but I'd be glad to provide more informations on request.

Thanks for your listening,
Omar Cornut





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/