Re: How to use AddressSanitizer with Wine?

Bernhard Übelacker <[email protected]> Tue, 6 May 2025 14:49:34 +0200
Newsgroups gmane.comp.emulators.wine.devel
Message-ID <[email protected]>
Am 28.04.25 um 06:44 schrieb Alex Henrie:
> On Sat, Apr 26, 2025 at 4:36 PM Bernhard Übelacker
> <[email protected]> wrote:
> 
>> For enabling ASan(PE) I collected some "notes to myself", which I hope
>> are enough accurate to enable someone else to reproduce the results.
> 
>> [6] https://gitlab.winehq.org/bernhardu/wine/-/blob/asan-pe_2025-04-05_wine-10.6/README-ASan.md?ref_type=heads
> 
> Thank you for sharing! Goodness, it's a lot more complicated than I
> had hoped. Notwithstanding the difficulty, following your instructions
> closely I was able to build and run Wine with the llvm-mingw AUR
> package.[1] My LLVM variables look like this:
> 
> export LLVM_INST_PATH=/opt/llvm-mingw
> export x86_64_LLVM_CLANG_RT_LIB=$(find $LLVM_INST_PATH -name
> libclang_rt.asan_dynamic-x86_64.dll.a)
> export i386_LLVM_CLANG_RT_LIB=$(find $LLVM_INST_PATH -name
> libclang_rt.asan_dynamic-i386.dll.a)
> 
> For my own sanity, I created scripts named configure64.sh, build64.sh,
> configure32.sh, build32.sh, and run.sh for the various steps of the
> instructions. I think it would be a lot easier to use your ASan branch
> if the commands were already in scripts.
> 
>> Unfortunately I have one patch with LLVM still in progress,
>> therefore a self-built LLVM would be needed, to build wine.
>> But this is just needed for HEAP_REALLOC_IN_PLACE_ONLY re-allocations,
>> and running with "windows_hook_rtl_allocators=0" should not be affected by this,
>> and that way building wine from the plain nightly llvm-mingw package should work.
> 
> Could you note that in the README please? Upstream llvm-mingw combined
> with windows_hook_rtl_allocators=1 resulted in the cryptic error
> "wine: could not load kernel32.dll, status c0000135" when trying to
> initialize and use the Wine prefix.
> 
> I ran a few parts of the Wine test suite and I've submitted my first
> patch based on the results.[2] Furthermore, since the instructions in
> the wiki were outdated and nonfunctional, I've replaced them with a
> link to your repository.[3] Thanks very much for all the work you put
> into it!
> 
> -Alex
> 
> [1] https://aur.archlinux.org/packages/llvm-mingw
> [2] https://gitlab.winehq.org/wine/wine/-/merge_requests/7925
> [3] https://gitlab.winehq.org/wine/wine/-/wikis/Building-Wine#memory--address-checkers


Hello Alex,
thanks for testing and fixing found issues.
I missed also in the readme I am using currently a new-style-wow64 configure.
Unfortunately I did not get around to put those parts into scripts.
However, I rebased to current release
and new test runs are in the asan_reports_x86(_64) subdirectories.

https://gitlab.winehq.org/bernhardu/wine/-/tree/asan-pe_2025-04-26_wine-10.7?ref_type=heads

Kind regards,
Bernhard