http://bugs.winehq.org/show_bug.cgi?id=59887 Bug ID: 59887 Summary: windowscodecs GIF decoder (CommonDecoder_Initialize) fails to load a valid multi-frame animated GIF; gdiplus then returns GenericError Product: Wine Version: 11.0 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: windowscodecs Assignee: wine-bugs@list.winehq.org Reporter: mcmarius@gmx.net Distribution: --- ## Description Loading a particular valid animated GIF through GDI+ (`GdipLoadImageFromFile` / `GdipLoadImageFromStream`) fails. GDI+ delegates to the builtin WIC GIF decoder (`CLSID_WICGifDecoder`, `{1f8a5601-7d4d-4cbd-9c82-1bc8d4eeb9a5}`) and the decoder's `CommonDecoder_Initialize` fails, so GDI+ reports `ExternalException: A generic error occurred in GDI+`. When the same image is consumed by a WinForms application via designer resources (`ComponentResourceManager.GetObject` → `Bitmap` → `PictureBox.Image`), the failure surfaces later as `System.ArgumentException: Parameter is not valid` at `System.Drawing.Image.get_FrameDimensionsList()` (called from `ImageAnimator.CanAnimate` when the PictureBox is parented), which crashes the app. On native Windows the same GIF loads and animates fine. This affects any .NET WinForms / GDI+ application that displays such GIFs. It was originally found because it crashes the "SpellForce 3 Universal Reforced Content Patch" installer at startup (its animated intro logo). ## Steps to reproduce 1. Take the attached `a_0_and_38.gif` (146 KB, 2 frames — a minimal cut of the original 249-frame animation that still reproduces). 2. Load it with builtin gdiplus, e.g. the attached `Repro.exe`: `WINEDLLOVERRIDES="gdiplus=b;windowscodecs=b" wine Repro.exe a_0_and_38.gif` `Repro.cs` (compiled with the in-prefix csc): ```csharp using System; using System.Drawing; using System.Drawing.Imaging; using System.IO; class Repro { static void Main(string[] a){ using (Image img = Image.FromStream(new MemoryStream(File.ReadAllBytes(a[0])))) Console.WriteLine("frames=" + img.GetFrameCount(FrameDimension.Time)); } } ``` ## Current behavior `System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.` (builtin gdiplus + builtin windowscodecs, verified via `WINEDEBUG=+loaddll`). The `+wincodecs` trace ends at: ``` trace:wincodecs:CommonDecoder_Initialize (...,...,1) trace:wincodecs:CommonDecoder_Release (...) refcount=0 ``` i.e. `CommonDecoder_Initialize` returns failure. ## Expected behavior The GIF loads; `GetFrameCount(FrameDimension.Time)` returns the number of frames and the image animates (matches native Windows). ## Analysis / isolation - It is **not** the native gdiplus/windowscodecs path (this report is strictly about the builtin path; native DLLs are not expected to work under Wine). - It is **not** size, total memory, or frame count: synthetic GIFs of 800x450 with up to 249 frames (full or partial frames, global palette, disposal=1, min-code-size 8) all load fine under builtin gdiplus. - By losslessly truncating the original 249-frame GIF (keeping the original frame bytes), the failure was isolated to a **single frame, index 38 (0-based)**: - first 38 frames → loads OK (`trunc_38.gif`, 3.68 MB) - first 39 frames → fails (`trunc_39.gif`, 3.80 MB) - a 39-frame file where frame 38 is replaced by an earlier frame → loads OK - `frame 0 + frame 38` alone (146 KB, `a_0_and_38.gif`) → **fails** - Frame 38 descriptor: position (0,27), size 800x423, no local color table (uses the global 256-color table), not interlaced, LZW min code size 8, disposal=1. Structurally similar to its neighbours (which load), so the trigger is in that frame's image data / decode path, not an obviously malformed descriptor. The exact decode divergence (likely in `dlls/windowscodecs/gifformat.c` / the bundled GIF reader used by `CommonDecoder_Initialize`) needs source-level debugging. ## Attachments - `a_0_and_38.gif` — minimal reproducer (146 KB, 2 frames) - `trunc_38.gif` (works) / `trunc_39.gif` (fails) — off-by-one-frame pair - `pb3_exact.gif` — the full original 249-frame image (25 MB) - `Repro.exe` / `Repro.cs` — loader ## Environment - Wine 11.0 (Staging), Fedora 44 (x86_64) - .NET Framework 4.8 installed in the prefix (only used to surface the original crash; the bug reproduces with the plain `Repro.exe` loader above) -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.