Skip to content

Random crash in SystemResPool.GetSolidBrush #41

@marius-klimantavicius

Description

@marius-klimantavicius

Platform windows.

Note that it is rare and mostly happened to me when running AOT version of our app.

Steps to reproduce:

  1. Do not use visual styles (don't know if that's relevant or not though)
  2. Show message box before creating a form

Expected result:
Message box is shown correctly

Actual result:
Rarely a .NET exception dialog is shown saying that An item with the same key has already been added.

I could not debug it locally so I don't know what is causing this (especially because it is within lock - maybe recursive call due to recursive message - I don't know). Fix is to always update the dictionary/hashtable instead of trying to add:

SolidBrush brush = new SolidBrush(color);
solidbrushes[hash] = brush; // <-- instead of Add
return brush;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions