GdiPlus ValidateBitmapInfo crash

Marcio 1 Reputation point
2022-04-07T19:18:17.95+00:00

I was assigned to review a crash that affect a few users sporadically. Program is written in C++ (no clr). The call stack of the crash is:

GdiPlus!ValidateBitmapInfo
GdiPlus!CopyOnWriteBitmap::CopyOnWriteBitmap
GdiPlus!CopyOnWriteBitmap::Create
GdiPlus!GpBitmap::GpBitmap
GdiPlus!GdipCreateBitmapFromGdiDib
MyApp!Gdiplus::Bitmap::{ctor}

The crash seems to be random, environmental, and complex (impossible) to reproduce user steps.

Could this crash be caused by memory fault?

I can see some debug data from the DUMP file. BitmapInfoHeader seems to be correct:

{
  biSize=40
  biWidth=1224
  biHeight=1584
  biPlanes=1
  biBitCount=8
  biCompression=0
  biSizeImage=1938816
  biXPelsPerMeter=5669
  biYPelsPerMeter=5669
  biClrUsed=0
  biClrImportant=0
}

Pointer with data was copied and allocated in a std::vector prior to building the GdiPlus::Bitmap.

This is what comes from Visual Studio opening the miniDump file:

Unhandled exception at 0x73EF12D3 (GdiPlus.dll) in file.dmp: 0xC0000005: Access violation reading location 0x06101002.

Please, any help is welcome!

Best regards
Márcio

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,629 questions
{count} votes