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

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

@clin1234
clin1234 force-pushed the critical_sections branch 2 times, most recently from 0804b2b to 1b042a8 Compare August 23, 2026 09:56
@clin1234
clin1234 force-pushed the critical_sections branch 2 times, most recently from 249a8d9 to 96f0413 Compare August 27, 2026 11:57
@clin1234

Copy link
Copy Markdown
Author

I do not know why the the AppVeyor stage is failing everywhere:

https://ci.appveyor.com/project/matplotlib/matplotlib/builds/54613753

Command exited with code 1
python tools/visualize_tests.py --no-browser
Traceback (most recent call last):
  File "C:\projects\matplotlib\tools\visualize_tests.py", line 160, in <module>
    run(show_browser=not args.no_browser)
  File "C:\projects\matplotlib\tools\visualize_tests.py", line 64, in run
    for name in os.listdir(image_dir)
                ^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'result_images'
Command exited with code 1

@rcomer

rcomer commented Aug 28, 2026

Copy link
Copy Markdown
Member

Appveyor is now fixed by #32242, so if you rebase it should pass.

…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>
@melissawm melissawm mentioned this pull request Sep 7, 2026
5 tasks
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.

3 participants