Skip to content

Add mutexes around usage of FT_Library - #32096

Open
clin1234 wants to merge 2 commits into
matplotlib:mainfrom
clin1234:critical_sections
Open

Add mutexes around usage of FT_Library#32096
clin1234 wants to merge 2 commits into
matplotlib:mainfrom
clin1234:critical_sections

Conversation

@clin1234

Copy link
Copy Markdown

Resolve (mostly) #31424 and #32065

@QuLogic

QuLogic commented Jul 22, 2026

Copy link
Copy Markdown
Member

Annotate pyi files to match C++ interfaces, and add mutexes around usage of PyFT2Font and FT_Library

These are unrelated things, and belong in separate PRs.

@clin1234 clin1234 changed the title Annotate pyi files to match C++ interfaces, and add mutexes around usage of PyFT2Font and FT_Library Add mutexes around usage of PyFT2Font and FT_Library Jul 22, 2026
@clin1234 clin1234 changed the title Add mutexes around usage of PyFT2Font and FT_Library Add mutexes around usage of FT_Library Jul 22, 2026
@clin1234
clin1234 marked this pull request as ready for review July 22, 2026 22:42
@clin1234

Copy link
Copy Markdown
Author

@QuLogic Ping

…r boundary

- RendererAgg: hold pixBuffer, alphaBuffer and hatchBuffer in
  std::unique_ptr<agg::int8u[]> so they cannot leak, and drop the
  now-empty manual destructor
- FT2Image: allocate via calloc(width, height) so the size multiplication
  is overflow-checked, and throw std::bad_alloc on failure
- PyFT2Font_init: build the object in a unique_ptr and release() only on
  success, so a font that fails to open does not leak
- mpl_GetCurrentProcessExplicitAppUserModelID: free the COM-allocated
  string even if py::cast throws
- QhullInfo: delete the copy constructor and copy assignment, since it
  uniquely owns qh and error_file
- PyFT2Font: add a recursive_mutex taken only at the wrapper boundary, so
  concurrent calls on the same font under free-threading cannot corrupt
  its glyph slot, glyph list or image buffer

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants