https://bugs.winehq.org/show_bug.cgi?id=48492
Bug ID: 48492 Summary: XCP-ng Center v8.x (.NET 4.6 app) crashes on startup (WIC BmpDecoder does not support 32bpp RGBA format) Product: Wine Version: 5.0-rc6 Hardware: x86-64 OS: Linux Status: NEW Severity: normal Priority: P2 Component: windowscodecs Assignee: wine-bugs@winehq.org Reporter: focht@gmx.net Distribution: ---
Hello folks,
a user on IRC #winehq asked about the app.
Project homepage:
https://github.com/xcp-ng/xenadmin
Downloads:
https://github.com/xcp-ng/xenadmin/releases/tag/v8.0.1.26
Prerequisite: 'winetricks -q dotnet462'
--- snip --- $ pwd /home/focht/.wine/drive_c/Program Files/XCP-ng Center
$ wine ./XCP-ng\ Center.exe 0009:fixme:wincodecs:BmpDecoder_ReadHeaders unsupported bitfields type depth=32 red=ff000000 green=ff0000 blue=ff00 alpha=ff 0009:fixme:wincodecs:WICConvertBitmapSource cannot convert {6fddc324-4e03-4bfe-b185-3d77768dc900} to {6fddc324-4e03-4bfe-b185-3d77768dc90f} ... 0009:err:eventlog:ReportEventW L"Application: XCP-ng Center.exe\nFramework Version: v4.0.30319\nDescription: The process was terminated due to an unhandled exception.\nException Info: System.Runtime.InteropServices.ExternalException\n at System.Drawing.Image.FromStream(System.IO.Stream, Boolean, Boolean)\n at splash_"... 0009:fixme:advapi:DeregisterEventSource (0xcafe4242) stub
Unhandled Exception: 0009:fixme:ver:GetCurrentPackageId (0x32c9a0 (nil)): stub System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) at splash_xcp_ng.SplashForm.Style() at splash_xcp_ng.SplashForm..ctor() at splash_xcp_ng.Program.Main() wine: Unhandled exception 0xe0434352 in thread 9 at address 7B00DAB1 (thread 0009), starting debugger... --- snip ---
Trace log:
--- snip --- $ WINEDEBUG=+seh,+relay,+gdiplus,+wincodecs wine ./XCP-ng\ Center.exe >>log.txt 2>&1 ... 002c:trace:gdiplus:GdipLoadImageFromStream 06390030 0032F450 ... 002c:trace:gdiplus:initialize_decoder_wic 06390030,{0af1d87e-fcfe-4188-bdeb-a7906471cbe3} ... 002c:trace:wincodecs:BmpDecoder_ReadHeaders bitmap header=124 compression=3 depth=32 002c:fixme:wincodecs:BmpDecoder_ReadHeaders unsupported bitfields type depth=32 red=ff000000 green=ff0000 blue=ff00 alpha=ff 002c:trace:gdiplus:decode_frame_wic 03C2F3E0,0,0032F450 002c:trace:wincodecs:BmpDecoder_AddRef (0x3c2f3e0) refcount=2 002c:trace:wincodecs:BmpFrameDecode_GetPixelFormat (0x3c2f3e4,0x32f280) ... 002c:Call windowscodecs.WICConvertBitmapSource(061352d0,03c2f3e4,0032f27c) ret=0611d193 002c:trace:wincodecs:WICConvertBitmapSource {6fddc324-4e03-4bfe-b185-3d77768dc90f},0x3c2f3e4,0x32f27c 002c:trace:wincodecs:BmpFrameDecode_GetPixelFormat (0x3c2f3e4,0x32f154) ... 002c:trace:wincodecs:ComponentEnum_Reset (0x3c2f630) 002c:trace:wincodecs:ComponentEnum_Next (0x3c2f630,1,0x32f140,0x32f150) 002c:trace:wincodecs:FormatConverterInfo_AddRef (0x3c2f820) refcount=3 002c:trace:wincodecs:FormatConverterInfo_QueryInterface (0x3c2f820,{9f34fb65-13f4-4f15-bc57-3726b5e53d9f},0x32f144) 002c:trace:wincodecs:FormatConverterInfo_AddRef (0x3c2f820) refcount=4 002c:Call advapi32.RegOpenKeyExW(000001b4,f6e43470 L"PixelFormats",00000000,00020019,0032f108) ret=f6de9b81 ... 002c:Ret advapi32.RegOpenKeyExW() retval=00000000 ret=f6de9b81 002c:Call advapi32.RegOpenKeyExW(00000188,0032f164 L"{6FDDC324-4E03-4BFE-B185-3D77768DC900}",00000000,00020019,0032f10c) ret=f6de9ba7 ... 002c:Ret advapi32.RegOpenKeyExW() retval=00000002 ret=f6de9ba7 ... 002c:trace:wincodecs:FormatConverterInfo_Release (0x3c2f820) refcount=3 002c:trace:wincodecs:FormatConverterInfo_Release (0x3c2f820) refcount=2 002c:trace:wincodecs:ComponentEnum_Next (0x3c2f630,1,0x32f140,0x32f150) 002c:trace:wincodecs:ComponentEnum_Release (0x3c2f630) refcount=0 002c:trace:wincodecs:FormatConverterInfo_Release (0x3c2f820) refcount=1 ... 002c:Ret KERNEL32.HeapFree() retval=00000001 ret=f6dea627 002c:fixme:wincodecs:WICConvertBitmapSource cannot convert {6fddc324-4e03-4bfe-b185-3d77768dc900} to {6fddc324-4e03-4bfe-b185-3d77768dc90f} 002c:Ret windowscodecs.WICConvertBitmapSource() retval=88982f50 ret=0611d193 002c:trace:gdiplus:decode_frame_wic {6fddc324-4e03-4bfe-b185-3d77768dc900} => 0x26200a 002c:trace:wincodecs:BmpDecoder_Release (0x3c2f3e0) refcount=1 002c:Ret gdiplus.GdipLoadImageFromStream() retval=00000001 ret=04b6c0cb ... 002c:Call KERNEL32.RaiseException(e0434352,00000001,00000005,0032f33c) ret=00a9352f .. 002c:trace:seh:raise_exception code=e0434352 flags=1 addr=0x7b00dab1 ip=7b00dab1 tid=002c 002c:trace:seh:raise_exception info[0]=80004005 002c:trace:seh:raise_exception info[1]=00000000 002c:trace:seh:raise_exception info[2]=00000000 002c:trace:seh:raise_exception info[3]=00000000 002c:trace:seh:raise_exception info[4]=008e0000 002c:trace:seh:raise_exception eax=0032f244 ebx=00000005 ecx=0032f33c edx=0032f244 esi=00000005 edi=0032f2b0 002c:trace:seh:raise_exception ebp=0032f298 esp=0032f244 cs=320023 ds=ffff002b es=002b fs=f7be0063 gs=006b flags=00000216 --- snip ---
Managed app code call site:
--- snip --- private void Style() { this.labelVersion.Text = this.ProductVersion + " (Build " + (object) this.AssemblyVersion + ")"; this.assembly = Assembly.LoadFrom(Application.ExecutablePath); this.stream = this.assembly.GetManifestResourceStream("splash_xcp_ng.Resources.splash.bmp"); Image image = Image.FromStream(this.stream); this.FormBorderStyle = FormBorderStyle.None; this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this.BackgroundImage = image; this.BackgroundImageLayout = ImageLayout.Stretch; this.Width = image.Width; this.Height = image.Height; this.CenterToScreen(); } --- snip ---
Dumped information from extracted .bmp (assembly resources):
--- snip --- $ identify -verbose splash_xcp_ng.Resources.splash.bmp
Image: splash_xcp_ng.Resources.splash.bmp Format: BMP (Microsoft Windows bitmap image) Class: DirectClass Geometry: 415x217+0+0 Resolution: 28.34x28.34 Print size: 14.6436x7.65702 Units: PixelsPerCentimeter Colorspace: sRGB Type: TrueColorAlpha Base type: Undefined Endianess: Undefined Depth: 8-bit Channel depth: red: 8-bit green: 8-bit blue: 8-bit alpha: 1-bit Channel statistics: Pixels: 90055 Red: min: 0 (0) max: 255 (1) mean: 207.743 (0.81468) standard deviation: 48.6337 (0.19072) kurtosis: 7.97873 skewness: -2.9306 entropy: 0.754373 Green: min: 0 (0) max: 255 (1) mean: 207.124 (0.812251) standard deviation: 47.7944 (0.187429) kurtosis: 6.57435 skewness: -2.68243 entropy: 0.757905 Blue: min: 0 (0) max: 255 (1) mean: 207.299 (0.812936) standard deviation: 46.8957 (0.183905) kurtosis: 6.42342 skewness: -2.64095 entropy: 0.758985 Alpha: min: 255 (1) max: 255 (1) mean: 255 (1) standard deviation: 0 (0) kurtosis: 8.192e+63 skewness: 1e+45 entropy: 0 Image statistics: Overall: min: 0 (0) max: 255 (1) mean: 219.291 (0.859966) standard deviation: 35.8309 (0.140514) kurtosis: 8.34837 skewness: -2.79921 entropy: 0.567816 Rendering intent: Relative Chromaticity: red primary: (0,0) green primary: (0,0) blue primary: (0,0) white point: (0.3127,0.329) Background color: white Border color: srgba(223,223,223,1) Matte color: grey74 Transparent color: none Interlace: None Intensity: Undefined Compose: Over Page geometry: 415x217+0+0 Dispose: Undefined Iterations: 0 Compression: Undefined Orientation: Undefined Properties: date:create: 2020-01-21T22:30:19+01:00 date:modify: 2020-01-21T22:30:19+01:00 signature: dc1ce4626e58781d380b4fd283d6e2df82f66930394cc4b248f2872115b7fd6f Artifacts: filename: splash_xcp_ng.Resources.splash.bmp verbose: true Tainted: False Filesize: 360358B Number pixels: 90055 Pixels per second: 9.0055MB User time: 0.000u Elapsed time: 0:01.010 Version: ImageMagick 6.9.9-38 Q16 x86_64 2018-03-12 http://www.imagemagick.org --- snip ---
Via virustotal.com:
https://www.virustotal.com/gui/file/8b9f551cbd682648d5c9282db4d953d1f34b90c0...
Debugger:
--- snip ---
Wine-gdb> bt #0 0xf6dfd57e in BmpDecoder_Initialize (iface=<optimized out>, pIStream=<optimized out>, cacheOptions=<optimized out>) at /home/focht/projects/wine/mainline-src/dlls/windowscodecs/bmpdecode.c:863
...
Wine-gdb> p *This $7 = {IWICBitmapDecoder_iface = {lpVtbl = 0xf6e632c0 <BmpDecoder_Vtbl>}, IWICBitmapFrameDecode_iface = {lpVtbl = 0xf6e63300 <BmpDecoder_FrameVtbl>}, ref = 1, initialized = 0, stream = 0x0, palette_offset = 138, image_offset = 138, bih = {bV5Size = 124, bV5Width = 415, bV5Height = 217, bV5Planes = 1, bV5BitCount = 32, bV5Compression = 3, bV5SizeImage = 360220, bV5XPelsPerMeter = 2834, bV5YPelsPerMeter = 2834, bV5ClrUsed = 0, bV5ClrImportant = 0, bV5RedMask = 4278190080, bV5GreenMask = 16711680, bV5BlueMask = 65280, bV5AlphaMask = 255, bV5CSType = 1934772034, bV5Endpoints = {ciexyzRed = {ciexyzX = 0, ciexyzY = 0, ciexyzZ = 0}, ciexyzGreen = {ciexyzX = 0, ciexyzY = 0, ciexyzZ = 0}, ciexyzBlue = {ciexyzX = 0, ciexyzY = 0, ciexyzZ = 0}}, bV5GammaRed = 0, bV5GammaGreen = 0, bV5GammaBlue = 0, bV5Intent = 2, bV5ProfileData = 0, bV5ProfileSize = 0, bV5Reserved = 0}, pixelformat = 0x4c004c, bitsperpixel = 0, read_data_func = 0x0, stride = 0, imagedata = 0x0, imagedatastart = 0x0, lock = {DebugInfo = 0x3c16ce8, LockCount = 0, RecursionCount = 1, OwningThread = 0x53, LockSemaphore = 0x0, SpinCount = 0}, packed = 0, icoframe = 0}
Wine-gdb> p/x This->bih.bV5RedMask $9 = 0xff000000
Wine-gdb> p/x This->bih.bV5GreenMask $10 = 0xff0000
Wine-gdb> p/x This->bih.bV5BlueMask $11 = 0xff00
Wine-gdb> p/x This->bih.bV5AlphaMask $12 = 0xff --- snip ---
Microsoft docs:
https://docs.microsoft.com/en-us/windows/win32/wic/-wic-codec-native-pixel-f...
$ sha1sum XCP-ng-Center-8.0.1.26.msi 001d450f89cb470146b87c771362bacdacbaa945 XCP-ng-Center-8.0.1.26.msi
$ du -sh XCP-ng-Center-8.0.1.26.msi 7.2M XCP-ng-Center-8.0.1.26.msi
$ wine --version wine-5.0-rc6
Regards
https://bugs.winehq.org/show_bug.cgi?id=48492
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- URL| |https://github.com/xcp-ng/x | |enadmin/releases/download/v | |8.0.1.26/XCP-ng-Center-8.0. | |1.26.msi Keywords| |download
https://bugs.winehq.org/show_bug.cgi?id=48492
imirkin@alum.mit.edu changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |imirkin@alum.mit.edu
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #1 from imirkin@alum.mit.edu --- While I'm hardly an expert in Windows BMP decoding standards, it looks like the dlls/windowscodecs/bmpdecode.c::bitfields_formats only has 32bppBGRA, while this appears to be 32bppABGR. Of course there's no such standard GUID defined, perhaps this maps onto the 32bpp4Channels variant (although I don't see it at all in dlls/windowscodecs).
If someone with a deeper understanding of how this is all integrated can give me a concrete way that this should be handled, I'd be happy to implement the change.
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #2 from imirkin@alum.mit.edu --- Also, as Anastasius suggested on IRC, installing winetricks gdiplus and windowscodecs makes the application start just fine. I had only tried gdiplus prior to that. But it'd still be great to fix this in wine directly!
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #3 from Dmitry Timoshkov dmitry@baikal.ru --- Created attachment 66287 --> https://bugs.winehq.org/attachment.cgi?id=66287 patch
Attached patch should fix the problem.
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #4 from Dmitry Timoshkov dmitry@baikal.ru --- (In reply to Dmitry Timoshkov from comment #3)
Created attachment 66287 [details] patch
Attached patch should fix the problem.
I should note, that this is not a proper fix. A proper fix would imply converting to GUID_WICPixelFormat32bppBGRA when reading for compatibility with gdiplus.
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #5 from Ilia Mirkin imirkin@alum.mit.edu --- Right, the patch causes swapped colors since it's reinterpreting an ABGR image as if it were BGRA. But it does make the application load. Given that it's for the splash screen, not the end of the world...
https://bugs.winehq.org/show_bug.cgi?id=48492
Dmitry Timoshkov dmitry@baikal.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #66287|0 |1 is obsolete| |
--- Comment #6 from Dmitry Timoshkov dmitry@baikal.ru --- Created attachment 66288 --> https://bugs.winehq.org/attachment.cgi?id=66288 patch (v2)
Here's a hopefully proper fix.
https://bugs.winehq.org/show_bug.cgi?id=48492
Dmitry Timoshkov dmitry@baikal.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #66288|0 |1 is obsolete| |
--- Comment #7 from Dmitry Timoshkov dmitry@baikal.ru --- Created attachment 66289 --> https://bugs.winehq.org/attachment.cgi?id=66289 patch (v3)
Sorry, incorrect GUID slipped in v2.
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #8 from Vincent Povirk madewokherd@gmail.com --- Does native really have a special case for this format, or is it converting bitfields in the general case?
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #9 from Ilia Mirkin imirkin@alum.mit.edu --- The only guidance I see regarding what can be in the bitfields is from https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapv5...
""" When the bV5Compression member is BI_BITFIELDS, bits set in each DWORD mask must be contiguous and should not overlap the bits of another mask. All the bits in the pixel do not need to be used. """
So it probably has to handle arbitrary(ish) masks. The patch from Dmitry also does in-place fixups to the data -- is that acceptable? Without knowing more, I would have assumed that the data comes from the application or is otherwise read-only.
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #10 from Ilia Mirkin imirkin@alum.mit.edu --- https://en.wikipedia.org/wiki/BMP_file_format#Pixel_format
Also seems to suggest that arbitrary bitfields can be specified. Probably should just go off of bitsize and create specialized 16/24/32-bit-wide functions to handle the different bitfields, and use a fixed pixel format for each width?
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #11 from Ilia Mirkin imirkin@alum.mit.edu --- Created attachment 66292 --> https://bugs.winehq.org/attachment.cgi?id=66292 more generic patch
This makes the splash screen display correctly. I'll look at adding some tests if it's reasonably easy.
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #12 from Esme Povirk madewokherd@gmail.com --- Created attachment 67214 --> https://bugs.winehq.org/attachment.cgi?id=67214 test
I wrote a test for this. It seems native accepts arbitrary bitfields, but it converts them to 32bppBGR, ignoring alpha information.
https://bugs.winehq.org/show_bug.cgi?id=48492
--- Comment #13 from Rafał Mużyło galtgendo@o2.pl --- On a semi-random note: for quite awhile, I've been locally using a trivial patch, that changed in dlls/windowscodecs/bmpencode.c '#if 0' to '#if 1' for the line with GUID_WICPixelFormat32bppBGRA.
That was needed in some random game to get some things to display.
Perhaps that part needs another look too.
https://bugs.winehq.org/show_bug.cgi?id=48492
Rafał Mużyło galtgendo@o2.pl changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |galtgendo@o2.pl
https://bugs.winehq.org/show_bug.cgi?id=48492
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch, testcase URL|https://github.com/xcp-ng/x |https://web.archive.org/web |enadmin/releases/download/v |/20200314074410/https://git |8.0.1.26/XCP-ng-Center-8.0. |hub.com/xcp-ng/xenadmin/rel |1.26.msi |eases/download/v8.0.1.26/XC | |P-ng-Center-8.0.1.26.msi
--- Comment #14 from Anastasius Focht focht@gmx.net --- Hello folks,
adding stable link via Internet Archive:
https://web.archive.org/web/20200314074410/https://github.com/xcp-ng/xenadmi...
You need to wait a few seconds if it says "Got an HTTP 302 response at crawl time", it will still resolve to the artifact snapshot.
$ wine --version wine-6.0-rc6
Regards
https://bugs.winehq.org/show_bug.cgi?id=48492
Esme Povirk madewokherd@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |madewokherd@gmail.com