On Tue Oct 18 15:31:21 2022 +0000, Jinoh Kang wrote:
> > Then what happens here if `find_ordinal_export` finds another
> transitive forwarded export? Should we still keep the same `current_modref`?
> Yes, we should. The importer DLL references the eventual DLL the target
> object resides in, not any of the intermediate DLL in the forward chain.
> > Should we add the second forwarded module to the first one
> dependencies instead?
> No, we should only add the last non-forwarding module to the importer
> DLL's dependencies.
Also note that the forward[1-3] DLLs are exactly designed to test transitively forwarded exports.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7#note_11158
> Then what happens here if `find_ordinal_export` finds another transitive forwarded export? Should we still keep the same `current_modref`?
Yes, we should. The importer DLL references the eventual DLL the target object resides in, not any of the intermediate DLL in the forward chain.
> Should we add the second forwarded module to the first one dependencies instead?
No, we should only add the last non-forwarding module to the importer DLL's dependencies.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7#note_11157
With this commit the following functions were implemented:
- _mbsupr_s_l - converts multibyte string to uppercase, by using specified locale that's passed in.
- _mbslwr_s_l - converts multibyte string to lowercase, by using specified locale that's passed in.
- _mbctolower_l - converts multibyte uppercase character to lowercase character, by using specified locale that's passed in.
- _mbctoupper_l - converts multibyte lowercase character to uppercase character, by using specified locale that's passed in.
More information about these methods are available at:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/strupr-s-…
After applying the patch the crash of the ChessBase application was fixed.
More information:
https://bugs.winehq.org/show_bug.cgi?id=45273
--
v7: msvcrt: implement missing CRT functions to fix ChessBase 14 crash
https://gitlab.winehq.org/wine/wine/-/merge_requests/1080
@rbernon Thanks for your review! Right now I'm tentatively putting this MR on hold until I find a solution for a memory leak: a new (redundant) dependency edge is added every time the application calls `GetProcAddress()` on a forwarded ref.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7#note_11151
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 $rcx, $rbp or $rsp.
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.
This change adds a bunch of convenience macros, to (hopefully)
improve readability of the CFI instructions.
Note: Those change was used with great success for unwinding through
the dispatcher using a modified LLDB shown in the
[“how-wine-works-101”](https://werat.dev/blog/how-wine-works-101/)
blog post as well as for in the [Orbit profiler](https://github.com/google/orbit),
that has mixed-callstack unwinding support.
Test: Inspect callstacks reported by the Orbit profiler while
running some Windows targets using the modified wine, as well as
verify debugging reports correct callstacks when stepping with our
modified LLDB through the dispatcher itself (so that we are able
to unwind through the dispatcher at any instruction).
--
v6: ntdll: Add CFI unwind info to __wine_syscall_dispatcher (x86_64)
https://gitlab.winehq.org/wine/wine/-/merge_requests/1065
Using a dedicated exit jmpbuf and removing the need for assembly
routines.
When Wine handles an exception in unix code, we return to user mode by
jumping to the last syscall frame. This can leave some pthread cancel
cleanups registered, in the pthread internal linked list, and at the
same time later overwrite the stack frame they were registered for.
In the same way, jumping to the exit frame on thread exit or abort, can
also leave some cleanup handlers registered for invalid stack frames.
Depending on the implementation, calling pthread_exit will cause all the
registered pthread cleanup handlers to be called, possibly jumping back
to now overwritten stack frames and causing segmentation faults.
Exiting a pthread normally, by returning from its procedure, or calling
exit(0) for the main thread doesn't run pthread_exit and doesn't call
cleanup handlers, avoiding that situation.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52213
### Additional note:
For robustness, we should probably try to execute these cleanup handlers
when unwinding the stack frames, as we would otherwise leave pthread
objects in a potential problematic state (like a mutex locked, etc).
It is however hard to do so when the handlers are registered from some C
code: pthread C implementation is done by calling some internal pthread
functions to register the handlers, and they aren't registered as
standard unwind handlers.
Only pthread_cancel and pthread_exit can unwind and call / unregister
the C handlers, but interrupting that procedure, for instance calling
setjmp / longjmp from withing our own handler isn't supported.
From C++ code, pthread cleanup handlers are registered through C++ class
constructors / destructors, and it would then be possible to partially
unwind and call them at the same time.
--
v2: ntdll: Remove unnecessary signal_start_thread register spilling.
ntdll: Remove unnecessary arch specific exit frame pointer.
ntdll: Avoid calling pthread_exit on thread exit.
loader: Allow __wine_main return without emitting a warning.
https://gitlab.winehq.org/wine/wine/-/merge_requests/1088
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 $rcx, $rbp or $rsp.
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.
This change adds a bunch of convenience macros, to (hopefully)
improve readability of the CFI instructions.
Note: Those change was used with great success for unwinding through
the dispatcher using a modified LLDB shown in the
[“how-wine-works-101”](https://werat.dev/blog/how-wine-works-101/)
blog post as well as for in the [Orbit profiler](https://github.com/google/orbit),
that has mixed-callstack unwinding support.
Test: Inspect callstacks reported by the Orbit profiler while
running some Windows targets using the modified wine, as well as
verify debugging reports correct callstacks when stepping with our
modified LLDB through the dispatcher itself (so that we are able
to unwind through the dispatcher at any instruction).
--
v5: ntdll: Add CFI unwind info to __wine_syscall_dispatcher (x86_64)
https://gitlab.winehq.org/wine/wine/-/merge_requests/1065
Rémi Bernon (@rbernon) commented about dlls/ntdll/loader.c:
> proc = find_ordinal_export( wm->ldr.DllBase, exports, exp_size,
> atoi(name+1) - exports->Base, load_path );
> } else
> proc = find_named_export( wm->ldr.DllBase, exports, exp_size, name, -1, load_path );
Then what happens here if `find_ordinal_export` finds another transitive forwarded export? Should we still keep the same `current_modref`? Should we add the second forwarded module to the first one dependencies instead?
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7#note_11123