On Mon May 19 08:23:31 2025 +0000, Nikolay Sivov wrote:
> I don't think this works, see [1]. You're freeing the same thing using
> two separate counters. My guess is that weak reference has to be a
> separate object, main object would keep a regular reference to it, once
> main thing is released it would clear itself from weak ref object. That
> will be an indication to fail Resolve(). I doesn't seem necessary to
> have multiple weak reference objects, that simplifies things.
> [1] https://gitlab.winehq.org/bernhardu/wine/-/blob/asan-pe_2025-05-06_wine-10.…
I will fix this. Thanks for spotting this.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/8053#note_103799
Nikolay Sivov (@nsivov) commented about dlls/windows.ui/uisettings.c:
> IUISettings3 IUISettings3_iface;
> IUISettings4 IUISettings4_iface;
> IUISettings5 IUISettings5_iface;
> - LONG ref;
> + IWeakReferenceSource IWeakReferenceSource_iface;
> + IWeakReference IWeakReference_iface;
> + LONG ref_strong;
> + LONG ref_weak;
> };
I don't think this works, see [1]. You're freeing the same thing using two separate counters. My guess is that weak reference has to be a separate object, main object would keep a regular reference to it, once main thing is released it would clear itself from weak ref object. That will be an indication to fail Resolve(). I doesn't seem necessary to have multiple weak reference objects, that simplifies things.
[1] https://gitlab.winehq.org/bernhardu/wine/-/blob/asan-pe_2025-05-06_wine-10.…
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/8053#note_103796
1. For %fs/fsbase the patch follows the macOS logic with LDT descriptor registration and Linux with switching. One notable difference is that on 32->64 transition we set %fs to GSEL(GUFS32_SEL, SEL_UPL) before restoring fsbase, otherwise FreeBSD will just revert it by reloading the selector [at the first opportunity](https://github.com/freebsd/freebsd-src/blob/5673462af5330df207…. GSEL(GUFS32_SEL, SEL_UPL) is the default %fs value on FreeBSD and is special-cased to save/restore actual fsbase value to/from PCB.
2. I was told we could get rid of fsbase glitches in signal handlers by blocking signals with [sigfastblock(2)](https://man.freebsd.org/cgi/man.cgi?query=sigfastblock) between %fs reset to the default value and fsbase reset to pthread_teb. This is currently a part of internal API for libthr, which could be exposed as pthread_signal_block_np for Wine. I'm on the fence whether it's worth it.
3. I fully admit I have no idea what registers are worth preserving around fallback syscalls to sysarch(AMD64_SET_FSBASE) and whether it's appropriate to push those to stack. ("Kernel" stack should be fine, I assume?) They definitely clobber r8-r11.
4. For %ss see https://lkml.org/lkml/2015/4/24/216. We don't have a similar workaround in the kernel, so it goes into Wine.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/8073