René's URL Explorer Experiment


Title: [Bug]: Umbrella issue: matplotlib C/C++ Extension Analysis Report · Issue #31424 · matplotlib/matplotlib · GitHub

Open Graph Title: [Bug]: Umbrella issue: matplotlib C/C++ Extension Analysis Report · Issue #31424 · matplotlib/matplotlib

X Title: [Bug]: Umbrella issue: matplotlib C/C++ Extension Analysis Report · Issue #31424 · matplotlib/matplotlib

Description: Bug summary This is an umbrella issue meant to present the findings of an analysis report so matplotlib developers and contributors can discuss them, figure out which are worth fixing, open individual issues and PRs, etc. Findings by Pri...

Open Graph Description: Bug summary This is an umbrella issue meant to present the findings of an analysis report so matplotlib developers and contributors can discuss them, figure out which are worth fixing, open individ...

X Description: Bug summary This is an umbrella issue meant to present the findings of an analysis report so matplotlib developers and contributors can discuss them, figure out which are worth fixing, open individ...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/31424

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Umbrella issue: matplotlib C/C++ Extension Analysis Report","articleBody":"### Bug summary\n\nThis is an umbrella issue meant to present the findings of an [analysis report](https://gist.github.com/devdanzin/2a79188c7a41a03b1476544c7dd775c1) so matplotlib developers and contributors can discuss them, figure out which are worth fixing, open individual issues and PRs, etc.\n\n## Findings by Priority\n\n### FIX\n\n1. **`std::string` constructed from NULL `ft_error_string`** — `ft_error_string()` returns NULL for unknown FreeType error codes. `THROW_FT_ERROR` constructs `std::string{nullptr}` — undefined behavior (typically crashes in `strlen`). Triggered when FreeType returns an error code not in the compiled-in list.\n   - `ft2font.h:39,52`\n\n2. **Inverted `PyErr_Occurred` logic in enum type caster** — `return !(ival == -1 \u0026\u0026 !PyErr_Occurred())` returns `true` (success) when `PyLong_AsLong` fails with an active exception. One-character fix: the `!` before `PyErr_Occurred()` should be removed.\n   - `_enums.h:83`\n\n3. **Unchecked `malloc` + leaked `Py_buffer` in `_copy_agg_buffer`** — `malloc(sizeof(Py_buffer))` not NULL-checked. If `PyObject_GetBuffer` fails, the buffer is leaked.\n   - `_macosx.m:1221-1225`\n\n4. **Unchecked `PyOS_double_to_string` — `strlen(NULL)` crash** — `PyOS_double_to_string()` can return NULL on OOM. `strlen(str)` follows without a NULL check. Crash confirmed under OOM injection.\n   - `_path.h:1070-1073`\n\n5. **`FigureCanvas_set_cursor` returns NULL without exception** — The `default:` case returns NULL without calling `PyErr_Set*`, causing `SystemError`.\n   - `_macosx.m:451`\n\n6. **`FigureManager__set_window_mode` returns NULL without exception** — When `self-\u003ewindow` is NULL (after `destroy()`), returns NULL without setting an exception.\n   - `_macosx.m:653-654`\n\n7. **NULL `char*` streamed to `std::stringstream` in `ft_glyph_warn`** — `face-\u003efamily_name` can be NULL. When NULL is inserted into `std::set\u003cFT_String*\u003e` and later streamed via `ss \u003c\u003c *it`, it's undefined behavior.\n   - `ft2font.cpp:457`, `ft2font_wrapper.cpp:410`\n\n8. **`NSFileHandle` leak in `wake_on_fd_write`** — `[[NSFileHandle alloc] initWithFileDescriptor: fd]` is never released.\n   - `_macosx.m:246-257`\n\n### CONSIDER\n\n9. **GIL not released during Agg rendering** — `draw_path`, `draw_markers`, `draw_path_collection`, etc. hold the GIL during software rasterization, blocking all threads. `_image_wrapper.cpp` already demonstrates the correct GIL-release pattern.\n   - `_backend_agg_wrapper.cpp:41-215`\n\n10. **GIL not released during Qhull triangulation** — 500K-point triangulation holds the GIL for 3+ seconds, reducing background thread throughput to 0.6% of baseline.\n    - `_qhull_wrapper.cpp:138-253`\n\n11. **Global `FT_Library` not thread-safe** — `_ft2Library` is shared across all threads. FreeType is not thread-safe for shared library instances.\n    - `ft2font.cpp:44`\n\n12. **FreeType stream read callback lacks GIL guard for free-threading** — Calls Python I/O without GIL guard on free-threaded builds.\n    - `ft2font_wrapper.cpp:367-388`\n\n13. **`ft_glyph_warn` calls Python APIs without GIL guard for free-threading** — Module import/attr access without GIL on free-threaded builds.\n    - `ft2font_wrapper.cpp:405-418`\n\n14. **Global `p11x::enums` map lacks synchronization** — `std::unordered_map` with `py::object` values, no synchronization for free-threading.\n    - `_enums.h:37`\n\n15. **`NSTrackingArea` leak in `FigureCanvas_init`** — `alloc` without matching `release`.\n    - `_macosx.m:378-382`\n\n16. **`Window.close` double-decref risk** — `Py_DECREF(manager)` if `dealloc` runs without prior `destroy`.\n    - `_macosx.m:1177-1188`\n\n17. **`PyFT2Font_init` leaks on exception** — Raw `new` without `unique_ptr`. ~59 bytes leaked per failed font construction (corrupt font file), ~131 bytes per failed construction (failing file-like object).\n    - `ft2font_wrapper.cpp:457-505`\n\n18. **Timer NSTimer captures raw `self` pointer** — Block captures Python object without `Py_INCREF`.\n    - `_macosx.m:1807-1816`\n\n19. **View stores raw `canvas` pointer** — No `Py_INCREF`, potential dangling pointer.\n    - `_macosx.m:139`\n\n20. **Exception clobbering in ft2font catch-all** — `catch(std::exception\u0026)` replaces meaningful errors (including `MemoryError`, `KeyboardInterrupt`) with generic `TypeError`.\n    - `ft2font_wrapper.cpp:492-494`\n\n21. **Unchecked `PyUnicode_EncodeFSDefault`** — NULL wrapped in `py::bytes`.\n    - `_tkagg.cpp:333-335`\n\n22. **`PyErr_Fetch`/`PyErr_Restore` deprecated since 3.12** — Should migrate to `PyErr_GetRaisedException`/`PyErr_SetRaisedException`.\n    - `ft2font_wrapper.cpp:394,402`\n\n23. **`PY_SSIZE_T_CLEAN` defines (×3)** — No-op since 3.10, can be removed.\n    - `mplutils.h`, `py_adaptors.h`, `_macosx.m`\n\n24. **Solaris `_XPG4`/`_XPG3` undefs** — Likely dead code.\n    - `mplutils.h:22-28`\n\n25. **macOS SDK \u003c 10.14 compat defines** — Likely dead code.\n    - `_macosx.m:11-16`\n\n\n\n### Code for reproduction\n\nSee https://gist.github.com/devdanzin/2a79188c7a41a03b1476544c7dd775c1#matplotlib-c-extension--reproducer-appendix for reproducers.\n\n### Actual outcome\n\n-\n\n### Expected outcome\n\n-\n\n### Additional information\n\nThe issue above is part of an analysis report created by [cext-review-toolkit](https://github.com/devdanzin/cext-review-toolkit), a Claude Code plugin for reviewing CPython C extensions. It covers the C/C++ source in `src/` (13 source files, 9 extension modules — 8 pybind11 + 1 raw Python/C API in `_macosx.m`).\n\nSome findings may be false positives or low-priority issues not worth fixing. Feedback on any misclassified findings is welcome.\n\nThe full report (including a reproducers appendix) is available at https://gist.github.com/devdanzin/2a79188c7a41a03b1476544c7dd775c1.\n\n### Operating system\n\nLinux\n\n### Matplotlib Version\n\nmain\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\ngit checkout","author":{"url":"https://github.com/devdanzin","@type":"Person","name":"devdanzin"},"datePublished":"2026-03-29T22:43:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/31424/matplotlib/issues/31424"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2617ddf9-f7d0-1c58-0462-99e20f5e7c1c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id96E2:13D32C:12A1857:19688D4:6A521653
html-safe-nonce6717848ea223719b12930e1d17eef7a02024d2538060ce27cd0500721b660186
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkUyOjEzRDMyQzoxMkExODU3OjE5Njg4RDQ6NkE1MjE2NTMiLCJ2aXNpdG9yX2lkIjoiNDE1Njk2ODY0NTY0ODU4NjMyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4532c74e806900a3ddcc871d63afef62a7e474c3ec2f56c3c112ea0f353a8738
hovercard-subject-tagissue:4165982181
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/31424/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c0afcf5f2b0d7287ddc9a737b4ce702b5a7ec65307ce74b5c5e11a1558920005/matplotlib/matplotlib/issues/31424
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c0afcf5f2b0d7287ddc9a737b4ce702b5a7ec65307ce74b5c5e11a1558920005/matplotlib/matplotlib/issues/31424
og:image:altBug summary This is an umbrella issue meant to present the findings of an analysis report so matplotlib developers and contributors can discuss them, figure out which are worth fixing, open individ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedevdanzin
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7aed05249554b889eb33d002851a973eebcc7e91
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/31424#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F31424
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F31424
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/31424
Reloadhttps://github.com/matplotlib/matplotlib/issues/31424
Reloadhttps://github.com/matplotlib/matplotlib/issues/31424
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/31424
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/31424
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.4k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 23k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 409 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality 0 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
#31610https://github.com/matplotlib/matplotlib/pull/31610
[Bug]: Umbrella issue: matplotlib C/C++ Extension Analysis Reporthttps://github.com/matplotlib/matplotlib/issues/31424#top
#31610https://github.com/matplotlib/matplotlib/pull/31610
Maintenancehttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22Maintenance%22
first-contributionhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22first-contribution%22
https://github.com/devdanzin
devdanzinhttps://github.com/devdanzin
on Mar 29, 2026https://github.com/matplotlib/matplotlib/issues/31424#issue-4165982181
analysis reporthttps://gist.github.com/devdanzin/2a79188c7a41a03b1476544c7dd775c1
https://gist.github.com/devdanzin/2a79188c7a41a03b1476544c7dd775c1#matplotlib-c-extension--reproducer-appendixhttps://gist.github.com/devdanzin/2a79188c7a41a03b1476544c7dd775c1#matplotlib-c-extension--reproducer-appendix
cext-review-toolkithttps://github.com/devdanzin/cext-review-toolkit
https://gist.github.com/devdanzin/2a79188c7a41a03b1476544c7dd775c1https://gist.github.com/devdanzin/2a79188c7a41a03b1476544c7dd775c1
Maintenancehttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22Maintenance%22
first-contributionhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22first-contribution%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.