Rémi Bernon (@rbernon) commented about dlls/ntdll/loader.c:
> " If you are using builtin %s, try using the native one instead.\n",
> forward, debugstr_w(get_modref(module)->ldr.FullDllName.Buffer),
> debugstr_w(get_modref(module)->ldr.BaseDllName.Buffer) );
> + if (wm) LdrUnloadDll( wm->ldr.DllBase );
> + }
> + else if (current_modref)
> + {
> + add_module_dependency( current_modref->ldr.DdagNode, wm->ldr.DdagNode );
Maybe we can then always add the module dependency after it's been loaded?
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7#note_11122
Rémi Bernon (@rbernon) commented about dlls/ntdll/loader.c:
>
> RtlEnterCriticalSection( &loader_section );
>
> - /* check if the module itself is invalid to return the proper error */
> - if (!get_modref( module )) ret = STATUS_DLL_NOT_FOUND;
> - else if ((exports = RtlImageDirectoryEntryToData( module, TRUE,
> - IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size )))
> + wm = get_modref( module );
> + if (!wm) ret = STATUS_DLL_NOT_FOUND;
> + else
> {
> - void *proc = name ? find_named_export( module, exports, exp_size, name->Buffer, -1, NULL )
> - : find_ordinal_export( module, exports, exp_size, ord - exports->Base, NULL );
> - if (proc)
> + prev = current_modref;
> + current_modref = wm;
I think you can simplify this a bit, by doing `if ((current_modref = get_modref(...)))`, after saving its previous value, and restoring it before leaving the CS.
Then I'm not sure what side effects this could have, and maybe it'd be better to have this specific change separate from the rest?
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7#note_11120
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.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/1088
--
v2: opengl32: Use the unixlib interface for WGL functions.
opengl32: Use the unixlib interface for EXT functions.
opengl32: Move the null functions to unix_thunks.c.
opengl32: Use the unixlib for glGet(String|Integerv).
opengl32: Create a unixlib interface for GL functions.
https://gitlab.winehq.org/wine/wine/-/merge_requests/1087