Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50955
The problem which this patchset aims to solve is (sometimes) huge timeout on TCP listening port availability on Linux after the listening socket was closed one or another way. By default, the listening port will also be blocked for the whole time accepted socket waits through lengthy timeouts (sometimes; most surely when the listening process with an active connection was force killed, but not limited to this condition).
BSD SO_REUSEADDR socket option is aimed mainly to avoid that extra wait on binding already closed listening socket address. From [1]: "Indicates that the rules used in validating addresses supplied in a bind(2) call should allow reuse of local addresses. For AF_INET sockets this means that a socket may bind, except when there is an active listening socket bound to the address.".
Unix SO_REUSEADDR does not really allow reusing address in the Winsock sense. It will just allow to ditch the timeout (which is always the case on Windows without any specific options). Unfortunately it is not the only effect of the option. It still won't allow listening on the address simultaneously (unlike Winsock SO_REUSEADDR which allows simultaneous listening), or binding to an address which is being listened. But it will allow to bind different sockets for the same address which is not the Winsock behaviour when Winsock SO_REUSEADDR is set.
So the patchset enables SO_REUSEADDR on every TCP socket and introduces the bound address tracking which will allow to return an error from bind() when needed.
Not related to this patchset, but Winsock SO_REUSEADDR is somewhat closer to BSD SO_REUSEPORT, although is different in a way that _REUSEPORT will load balance connections between listeners while with Winsock _REUSEADDR the connections will always go to the first listener.
I hope that the bound addresses tracking introduced in these patches may be reused in the future. E. g., maybe it might be helpful on the way of implementing the todos introduced by my extended tests (those todos are not related to this patchset and exist both with and without it).
1. https://man7.org/linux/man-pages/man7/socket.7.html
--
v5: ws2_32/tests: Also test bind to any together with loopback in a different order.
https://gitlab.winehq.org/wine/wine/-/merge_requests/1111
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50955
The problem which this patchset aims to solve is (sometimes) huge timeout on TCP listening port availability on Linux after the listening socket was closed one or another way. By default, the listening port will also be blocked for the whole time accepted socket waits through lengthy timeouts (sometimes; most surely when the listening process with an active connection was force killed, but not limited to this condition).
BSD SO_REUSEADDR socket option is aimed mainly to avoid that extra wait on binding already closed listening socket address. From [1]: "Indicates that the rules used in validating addresses supplied in a bind(2) call should allow reuse of local addresses. For AF_INET sockets this means that a socket may bind, except when there is an active listening socket bound to the address.".
Unix SO_REUSEADDR does not really allow reusing address in the Winsock sense. It will just allow to ditch the timeout (which is always the case on Windows without any specific options). Unfortunately it is not the only effect of the option. It still won't allow listening on the address simultaneously (unlike Winsock SO_REUSEADDR which allows simultaneous listening), or binding to an address which is being listened. But it will allow to bind different sockets for the same address which is not the Winsock behaviour when Winsock SO_REUSEADDR is set.
So the patchset enables SO_REUSEADDR on every TCP socket and introduces the bound address tracking which will allow to return an error from bind() when needed.
Not related to this patchset, but Winsock SO_REUSEADDR is somewhat closer to BSD SO_REUSEPORT, although is different in a way that _REUSEPORT will load balance connections between listeners while with Winsock _REUSEADDR the connections will always go to the first listener.
I hope that the bound addresses tracking introduced in these patches may be reused in the future. E. g., maybe it might be helpful on the way of implementing the todos introduced by my extended tests (those todos are not related to this patchset and exist both with and without it).
1. https://man7.org/linux/man-pages/man7/socket.7.html
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/1111
Called by IE11.
Signed-off-by: Mohamad Al-Jaf <mohamadaljaf(a)gmail.com>
v3: Fix failed test.
Don't know how to change the subject version number.
--
v2: shell32: Add SHBindToFolderIDListParent tests.
shell32: Implement SHBindToFolderIDListParent.
https://gitlab.winehq.org/wine/wine/-/merge_requests/566
--
v3: mshtml: Implement document.mimeType.
mshtml: Get rid of a EVENTID_LAST special case.
mshtml: Allow null or undefined func in addEventListener.
mshtml: Allow null or undefined listeners in attachEvent/detachEvent.
jscript: Implement VariantChangeType for VT_DISPATCH and VT_UNKNOWN.
https://gitlab.winehq.org/wine/wine/-/merge_requests/1172
So indeed attachEvent only does that when the ChangeType fails (no matter the error code).
Getting the mime type thing correct is challenging, but at least I managed to have all tests pass. I think I got it for the most part, and it should be fine for us to do it like this, but I had to add one "special case" in the tests for the w1064v1809 testbot VM because, for whatever reason, it uses the .htm extension to lookup the name, while .html is specified in the database. The CLSID also does not work correctly for it, either (it would show "HTML Document" instead of "HTM file")... I don't think this quirk is worth replicating.
Basically, first it looks up the Extension value in the database for that MIME type. If that is not found, or the extension lookup itself fails later or doesn't exist, it tries the CLSID from the database to obtain the ProgID.
I also test it in scripts via external.getExpectedMimeType, even though it seems overkill for now, because it will be useful later when testing more doc mime types (XHR response as well, for instance) and from others (anchors, etc). So it will be useful to have.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/1172#note_12385
Enforce proper atomic update so that other threads do not read stale
data from IO_STATUS_BLOCK.
Signed-off-by: Jinoh Kang <jinoh.kang.kr(a)gmail.com>
--
v8: ntdll: Fix reading stale Information from IOSB.
https://gitlab.winehq.org/wine/wine/-/merge_requests/155
Enforce proper atomic update so that other threads do not read stale
data from IO_STATUS_BLOCK.
Signed-off-by: Jinoh Kang <jinoh.kang.kr(a)gmail.com>
--
v7: ntdll: Fix reading stale Information from IOSB.
https://gitlab.winehq.org/wine/wine/-/merge_requests/155
This change is adding DWARF (CFI) unwind information to the
hand-written assembly of the `__wine_syscall_dispatcher` function.
This enables unwinding through the dispatcher from the Linux stack
into (and through) the Windows stack.
The general idea is that the `syscall_frame` struct contains the
content of the callee-save registers before the function call
(in particular the stack pointer and the return address). At any
point of the execution, we have a pointer into the `syscall_frame`
in $ebx, $ecx, $ebp, or $esp.
For the CFI codes the general idea is that we are defining the
computations of the callee-save registers based on the
`syscall_frame` using DWARF’s `breg` instruction, rather than
relative to CFA.
cc/ @florian-kuebler
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/1182
Overwatch 2 verifies that every kernel callback that is run, lives in user32. Introduce a callback in user32 that just forwards to the other modules' callbacks.
I don't know what to call this kind of callback, I just called it "user32 callback" for now because it's going through user32 but that's not really a good name.
It also sadly necessitates a private \_\_wine export from user32, unless someone has a better idea for how to register the callbacks with user32.
--
v3: user32: Remove NtUserDriverCallback* kernel callbacks.
winex11.drv: Convert kernel callbacks to user32 callbacks.
winemac.drv: Convert kernel callbacks to user32 callbacks.
wineandroid.drv: Convert kernel callbacks to user32 callbacks.
https://gitlab.winehq.org/wine/wine/-/merge_requests/1180
Overwatch 2 verifies that every kernel callback that is run, lives in user32. Introduce a callback in user32 that just forwards to the other modules' callbacks.
I don't know what to call this kind of callback, I just called it "user32 callback" for now because it's going through user32 but that's not really a good name.
It also sadly necessitates a private \_\_wine export from user32, unless someone has a better idea for how to register the callbacks with user32.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/1180
Overwatch 2 verifies that every kernel callback that is run, lives in user32. Introduce a callback in user32 that just forwards to the other modules' callbacks.
I don't know what to call this kind of callback, I just called it "user32 callback" for now because it's going through user32 but that's not really a good name.
It also sadly necessitates a private \_\_wine export from user32, unless someone has a better idea for how to register the callbacks with user32.
--
v2: user32: Remove NtUserDriverCallback* kernel callbacks.
winex11.drv: Convert kernel callbacks to user32 callbacks.
winemac.drv: Convert kernel callbacks to user32 callbacks.
wineandroid.drv: Convert kernel callbacks to user32 callbacks.
winevulkan: Convert kernel callbacks to user32 callbacks.
user.exe16: Convert kernel callbacks to user32 callbacks.
user32: Add user32 callback infrastructure.
https://gitlab.winehq.org/wine/wine/-/merge_requests/1180
Currently, unwinding the unix libraries (or full ELF builds) requires having libunwind available.
When starting up a wine environment, an exception of type `RPC_S_SERVER_UNAVAILABLE` gets thrown - and if libunwind isn't available, this breaks the startup. Thus, currently on ARM/ARM64, libunwind is essentially mandatory.
Additionally, at least on ARM, libunwind seems brittle (commits in latest git master breaks the unwinding use cases in Wine, see e.g. https://github.com/libunwind/libunwind/pull/203#issuecomment-984126066.
This MR tries to resolve all of this, by including the preexisting DWARF parser from x86_64 in the aarch64 version too. This bit was mostly quite straightforward.
For ARM, libunwind has currently relied on DWARF debug info in the `.debug_frame` section, since Linux on ARM doesn't use DWARF for runtime unwinding. This MR adds ARM EHABI unwind opcodes where necessary, and adds a local reimplementation of an ARM EHABI/EXIDX/EXTBL unwinder, similar to the DWARF one.
With these changes, unwinding on both ARM and ARM64 seems to work fine, even without libunwind.
See the individual commit messages for more commentary on the decisions taken so far (I've tried to write up all relevant considerations there - it's a fair amount of commentery).
A couple open questions:
- So far, the shared DWARF code was put in a header, `dwarf.h`. Do you want to make this a proper standalone `.c` file too?
- I wrote the ARM EHABI unwind code mostly with `stdint.h` types like `uint32_t`(as it's in the ntdll/unix directory anyway), but I can rewrite it with `DWORD` or similar if that's preferred.
- The ARM EHABI opcodes are enabled for `defined(__arm__) && defined(__ELF__) && defined(__GNUC__) && !defined(__SEH__) && !defined(__ARM_DWARF_EH__)` - there's no define to check for for knowing it's used and enabled, but it has to be implicitly assumed if no other other unwind mechanism is signaled.
- The `dl_iterate_phdr` function, used for finding the EXIDX section for locating ARM EHABI unwind info, is used within `#ifdef linux`. It might be available on other OSes too (like FreeBSD etc). Or should I go ahead and add a configure check for it?
CC @julliard @rbernon @AndreRH
--
v2: ntdll: Use the local dwarf implementation on arm64
ntdll: Add support for aarch64 in the dwarf implementation
ntdll: Move the dwarf reading routines to a shareable header
https://gitlab.winehq.org/wine/wine/-/merge_requests/1134