[PATCH 4/7] winebus.sys: Load SDL bus mappings before calling bus_init.

Bernhard Übelacker bernhardu at mailbox.org
Sun Sep 19 14:28:34 CDT 2021


Hello Rémi,
I had a 32-bit build configured with "--without-mingw" around,
that I updated in the last week a few times and wondered why since
a few days one of the winedevice.exe processes started crashing.


A git bisect leads to this commit:

         0017b5eb636ee4963636eaf83ae34f6077d695fd is the first bad commit
         commit 0017b5eb636ee4963636eaf83ae34f6077d695fd
         Author: Rémi Bernon <rbernon at codeweavers.com>
         Date:   Thu Sep 16 10:17:55 2021 +0200

             winebus.sys: Load SDL bus mappings before calling bus_init.
             
             Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
             Signed-off-by: Alexandre Julliard <julliard at winehq.org>

         dlls/winebus.sys/bus.h       | 30 ---------------
         dlls/winebus.sys/bus_iohid.c |  1 -
         dlls/winebus.sys/bus_sdl.c   | 69 +++++++++-------------------------
         dlls/winebus.sys/bus_udev.c  |  1 -
         dlls/winebus.sys/main.c      | 88 ++++++++++++++++++++++++++++++++++++++++++--
         dlls/winebus.sys/unixlib.h   |  3 ++
         6 files changed, 105 insertions(+), 87 deletions(-)
         delete mode 100644 dlls/winebus.sys/bus.h


This is a backtrace of such a crash:

         (rr) cont
         Continuing.

         Thread 2 received signal SIGSEGV, Segmentation fault.
         0x7bc42c9a in RtlEnterCriticalSection (crit=0x7e4a084c <device_list_cs>) at .../wine-git/wine-git/include/winnt.h:6485
         6485        return __sync_add_and_fetch( dest, 1 );
         1: x/i $pc
         => 0x7bc42c9a <RtlEnterCriticalSection+159>:    lock xadd %eax,(%edx)
         (rr) bt
         #0  0x7bc42c9a in RtlEnterCriticalSection (crit=0x7e4a084c <device_list_cs>) at .../wine-git/wine-git/include/winnt.h:6485
         #1  0x7e4a0e0e in bus_create_hid_device (desc=0xb1f4b4, unix_device=0x7e312af0) at .../wine-git/wine-git/dlls/winebus.sys/main.c:293
         #2  0x7e4a1791 in mouse_device_create () at .../wine-git/wine-git/dlls/winebus.sys/main.c:519
         #3  0x7e4a25b1 in fdo_pnp_dispatch (device=0x2485f0, irp=0x9102d8) at .../wine-git/wine-git/dlls/winebus.sys/main.c:773
         #4  0x7e4a2a04 in common_pnp_dispatch (device=0x2485f0, irp=0x9102d8) at .../wine-git/wine-git/dlls/winebus.sys/main.c:877
         #5  0x7e8cd668 in IoCallDriver (device=0x2485f0, irp=0x9102d8) at .../wine-git/wine-git/dlls/ntoskrnl.exe/ntoskrnl.c:1839
         #6  0x7e8d4a7b in send_pnp_irp (device=0x2485f0, minor=0 '\000') at .../wine-git/wine-git/dlls/ntoskrnl.exe/pnp.c:114
         #7  0x7e8d5346 in start_device (device=0x249a30, set=0x246a38, sp_device=0xb1f91e) at .../wine-git/wine-git/dlls/ntoskrnl.exe/pnp.c:302
         #8  0x7e8d7b55 in wine_enumerate_root_devices (driver_name=0x2428e8) at .../wine-git/wine-git/dlls/ntoskrnl.exe/pnp.c:1180
         #9  0x7e8d2860 in ZwLoadDriver (service_name=0xb1fdd8) at .../wine-git/wine-git/dlls/ntoskrnl.exe/ntoskrnl.c:3929
         #10 0x7eba57d9 in device_handler (ctrl=0, driver_name=0x242712) at .../wine-git/wine-git/programs/winedevice/device.c:77
         #11 0x7eba58c2 in service_handler (ctrl=2147483648, event_type=0, event_data=0x242712, context=0x245ec0) at .../wine-git/wine-git/programs/winedevice/device.c:104
         #12 0x7eb11fa1 in service_handle_control (service=0x245760, control=2147483648, data=0x242712, data_size=16) at .../wine-git/wine-git/dlls/sechost/service.c:1660
         #13 0x7eb12421 in service_control_dispatcher (arg=0x2457a0) at .../wine-git/wine-git/dlls/sechost/service.c:1745
         #14 0x7b64e728 in __fastcall_BaseThreadInitThunk () at .../wine-git/wine-git/dlls/kernel32/kernel_private.h:30
         #15 0x7bc7c48f in call_thread_func_wrapper () at .../wine-git/wine-git/dlls/ntdll/thread.c:191
         #16 0x7bc7c4f6 in call_thread_func (entry=0x7eb11fa9 <service_control_dispatcher>, arg=0x2457a0) at .../wine-git/wine-git/dlls/ntdll/thread.c:225
         #17 0x00000000 in ?? ()
         (rr) print/x $edx
         $3 = 0x7e4a0850
         (rr) when-tid
         Current tid: 2506348
         (rr) shell cat /proc/2506348/maps | grep -i 7e4a
         7e491000-7e4a4000 r-xp 00003000 08:01 172388224                          .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_4395_winebus.sys.so
         7e4a4000-7e4a6000 r--p 00016000 08:01 172388224                          .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_4395_winebus.sys.so
         7e4a6000-7e4a7000 r--p 00017000 08:01 172388224                          .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_4395_winebus.sys.so
         7e4a7000-7e4a8000 rw-p 00018000 08:01 172388224                          .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_4395_winebus.sys.so
         7e4a8000-7e4a9000 r--p 00000000 08:01 172385518                          .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_1008_version.dll.so
         7e4a9000-7e4b0000 r-xp 00001000 08:01 172385518                          .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_1008_version.dll.so
         (rr) info target
         ...
                 0x7e4a0050 - 0x7e4a35e9 is .text in .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_pack_59_winebus.sys.so
         ...
                 0x7e4a7020 - 0x7e4a7948 is .data in .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_pack_59_winebus.sys.so
         ...
         (rr) print dest
         $2 = (volatile LONG *) 0x7e4a0850 <device_list_cs+4>
         (rr) cont
         Continuing.
         wine: Unhandled page fault on write access to 7E4A0850 at address 7BC42C9A (thread 007c), starting debugger...
         006c:007c:trace:unixpid:CreateProcessInternalW app (null) cmdline L"winedbg --auto 108 80" :510


This looks like "device_list_cs" is part of the .text section,
which is not writable - might this be the issue here?

In an PE-build of winebus.sys device_list_cs is
stored in the .data section.

Now as I write this I remembered a similar issue in #47751,
where the place, some static variables have related to
some inline assembly, changed in which section they end up.

And indeed, when I move the static varibles right after the
debug channel declarations, then device_list_cs gets put
into the .data section and no crash happens.

Just wanted to forward the information in case
this "--without-mingw" configuration is still valid.

Kind regards,
Bernhard




More information about the wine-devel mailing list