[AD] crash! set_gfx_mode(GFX_TEXT...); vs draw_mouse()

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


fix / recommendation at bottom.


WHAT HAPPENED :

using:
msvc v6.0+sp3
win2k pro
wip 419.

crashed with the following message:

The instruction at "0xxx40f72e" ref'd mem at 0xddddddddd.
The memory could not be "read".


the debugger went to:
from  allegro/inline/draw.inl

AL_INLINE(void, draw_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y);

the sprite->vtable = 0xdddddddd
the x = -4096
the y = -4096
bmp->vtable->color_depth = 16



it occured when i called

set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);

after being in a DirectX Window, 16bit x 800 x 600.

1/2 way down the call stack shows
tim_win32_high_perf_thread(void* 0x0000000)

i suspect it might be some type of race condition...
it does not happen everytime, only about 50% of the time.
but when it does happen, it seems to crash in the same spot.

[later]

after recompiling the wip419 staticlink debug build
and then re-compiling all my code (after deleting the .pcb files(generated by msvc))

first run crashed out on the same spot, this time the call stack showed

draw_sprite(0x8374,0x3824, -4100 -4106)
draw_mouse(-1,-1);
mouse_move()
_handle_timer_tick(int 11934)
tim_win32_high_perf_thread(void* 0x000000);
_threadstart(...);
KERNEL32!


looks like a race condition when the screen is killed, the mouse (in another thread) attempting to draw on the screen.



FIX:

i put remove_mouse() before the call to set_gfx_mode(GFX_TEXT) and it seems to work.

RECOMMENDATION:

the documentation at remove_mouse() says "You don't normally need to bother calling this, because allegro_exit() will do it for you. "
to me, this says.  remove_mouse()  doesn't need to be called.
But a set_gfx_mode(GFX_TEXT) before allegro_exit() will make my program crash... well at least in win32 it does. As this probably only occurs in the win32 version of allegro, changing the docs seems wrong.

can remove_mouse() be called automatically by the set_gfx_mode() but only when the driver selected is GFX_TEXT. this will stop it from crashing, and the mouse will not be removed when changing to other gfx_modes. i do not see any reason why someone would want to set GFX_TEXT mode && leave the mouse driver still running.





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