race condition in dinput's multiple joystick code and IL2

Christoph Frick frick at sc-networks.de
Wed Jul 19 02:46:33 CDT 2006


hi there,

the code i submitted some weeks ago about having more than one
/dev/input/event-joystick shows from time to time a race condition in
IL2 Sturmovik. this game is written in java and somehow exe-fied. so the
whole thing is running a boatload of threads. my box is a
smp-opteron-system with gentoo and a 2.6.17 kernel.

my problem is the following (in dlls/dinput/joystick_linuxinput.c): the
new code calls a method (find_joydevs) on serveral places which checks
by a global variable, whether it ran before (have_joydevs) and then
builds up a list of the valid devices (joydevs). so what happes there is
a struct is filled on the stack and later memcpy-ied to the end of a
(re)alloced (HeapAlloc/HeapRealloc) list. things like the device are
strdup'ed from the stack into the struct before copy.

so in IL2 often - but not always - the have_joydevs has a count > -1,
the joydevs has a pointer. but when it access the "struct" behind it,
this is uninitialized memory (at least for the device-member) and random
errors occur.

so what i have tried so far:
- put find_joydevs into a critical section
- dont use strdup, but HeapAlloc+lstrcpyA

nothing helped. the only other thing that came this morning into my mind
but i have not yet tried to change, is the fact, that i malloc the
string and store the pointer to it in the struct. next thing is a memcpy
of the whole struct, which seems ok to my c-knowledge.

so if one of the wine gurus has some tips i would be glad to try them
out.

-- 
cu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20060719/319b295f/attachment.pgp


More information about the wine-devel mailing list