Title: [Bug]: Coredump when importing matplotlib.pyplot · Issue #25823 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Coredump when importing matplotlib.pyplot · Issue #25823 · matplotlib/matplotlib
X Title: [Bug]: Coredump when importing matplotlib.pyplot · Issue #25823 · matplotlib/matplotlib
Description: Bug summary When I execute python -c 'import matplotlib.pyplot', python will coredump. This will occur when it is generating the ~/.cache/matplotlib/fontlist-v330.json file, assuming that it was not already successfully generated. The ro...
Open Graph Description: Bug summary When I execute python -c 'import matplotlib.pyplot', python will coredump. This will occur when it is generating the ~/.cache/matplotlib/fontlist-v330.json file, assuming that it was no...
X Description: Bug summary When I execute python -c 'import matplotlib.pyplot', python will coredump. This will occur when it is generating the ~/.cache/matplotlib/fontlist-v330.json file, assuming that i...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/25823
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Coredump when importing matplotlib.pyplot","articleBody":"### Bug summary\n\nWhen I execute `python -c 'import matplotlib.pyplot'`, python will coredump. This will occur when it is generating the `~/.cache/matplotlib/fontlist-v330.json` file, assuming that it was not already successfully generated. \r\n\r\nThe root cause of the problem is that the `/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf` font will cause an `invalid pixel size` exception to be thrown from the FreeType library, the exception is not subsequently handled in the C++ layer, and python will abort.\n\n### Code for reproduction\n\n```python\n[ -f /usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf ] \\\r\n \u0026\u0026 /bin/rm -f ~/.cache/matplotlib/fontlist-v330.json \\\r\n \u0026\u0026 python -c \"import matplotlib.pyplot\"\n```\n\n\n### Actual outcome\n\n[1] 229645 abort (core dumped) python -c\n\n### Expected outcome\n\nNo output\n\n### Additional information\n\nIt appears that this is only caused by the NotoColorEmoji font. If I update font_manager.py to skip this font, there is no issue. \r\nThis was at least working in 3.1.3. I have tried 3.4.3 and 3.6.1 and they both have the same issue. I'm using system_freetype=True in the mplsetup.py file. I have also tried compiling FreeType and this does not seem to resolve anything.\r\n\r\nThe root cause of the problem is that the `/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf` font will cause an `invalid pixel size` exception to be thrown from the FreeType library, the exception is not subsequently handled in the C++ layer, and python will abort. \r\n\r\nI am using RedHat 7.6, 7.3 works fine because it does not have the problematic font. \r\n\r\nHere is a link to a similar issue using Pillow, [issue](https://github.com/python-pillow/Pillow/issues/6166). I'm not familiar with the code, but my understanding is that the correct solution would be the handle the FreeType exceptions in the ft2font_wrapper.cpp code and not propogate it into the Python interpreter.\r\n\r\nHere is part of the stack trace. \r\n\r\n\u003e #0 0x00007f7862cef207 in raise () from /lib64/libc.so.6\r\n\u003e #1 0x00007f7862cf08f8 in abort () from /lib64/libc.so.6\r\n\u003e #2 0x00007f784cfb2420 in _Unwind_SetGR (context=\u003coptimized out\u003e, index=\u003coptimized out\u003e, val=\u003coptimized out\u003e)\r\n\u003e at /tmp/gcc-v9.3.0p3/gcc.source/libgcc/unwind-dw2.c:1442\r\n\u003e #3 0x00007f784cfbe797 in __gcc_personality_v0 (version=\u003coptimized out\u003e, actions=\u003coptimized out\u003e, exception_class=\u003coptimized out\u003e, ue_header=0x15d9bf0, \r\n\u003e context=0x7fff105961e0) at /tmp/gcc-v9.3.0p3/gcc.source/libgcc/unwind-c.c:231\r\n\u003e #4 0x00007f785a69a7b3 in _Unwind_RaiseException_Phase2 () at /tmp/gcc-v9.3.0p4lnx86/gcc.source/libgcc/unwind.inc:64\r\n\u003e #5 0x00007f785a69acf1 in _Unwind_RaiseException (exc=0x15d9bf0) at /tmp/gcc-v9.3.0p4lnx86/gcc.source/libgcc/unwind.inc:136\r\n\u003e #6 0x00007f785a74a358 in __cxa_throw () from .../lib/64bit/libstdc++.so.6\r\n\u003e #7 0x00007f784cfb12a1 in **throw_ft_error**(std::__cxx11::basic_string\u003cchar, std::char_traits\u003cchar\u003e, std::allocator\u003cchar\u003e \u003e, int) [clone .cold] ()\r\n\u003e from .../lib/python3.9/site-packages/matplotlib-3.6.1-py3.9-linux-x86_64.egg/matplotlib/ft2font.cpython-39-x86_64-linux-gnu.so\r\n\u003e #8 0x00007f784cfb9868 in **PyFT2Font_init**(PyFT2Font*, _object*, _object*) () at /tmp/gcc-v9.3.0p3/gcc.source/libgcc/unwind-dw2.c:1442\r\n\n\n### Operating system\n\nRedHat 7.6\n\n### Matplotlib Version\n\n3.6.1\n\n### Matplotlib Backend\n\nCall to getBackend also crashes (same reason as above)\n\n### Python version\n\n3.9.16\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nNone","author":{"url":"https://github.com/john-odonovan","@type":"Person","name":"john-odonovan"},"datePublished":"2023-05-05T22:53:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":16},"url":"https://github.com/25823/matplotlib/issues/25823"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:00d14390-bef5-267a-44da-e29236320156 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C344:1AF501:14E175E:1B89A2D:6A51B9A6 |
| html-safe-nonce | ba04cb7b0163068ff78c46922b4c90e3af5b485faa8c1fe6c2354398e2a78029 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzQ0OjFBRjUwMToxNEUxNzVFOjFCODlBMkQ6NkE1MUI5QTYiLCJ2aXNpdG9yX2lkIjoiNTMwMTY0OTAyMjg0MjQxOTYyMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e44450fc8eeb1a72ee786f4871b906ff74a4d73227d11d708bd3160c6255224a |
| hovercard-subject-tag | issue:1698284049 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/25823/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7291679356b1b54719236e72d5daebc8aff16dc3118b051cbf56e112d99bc530/matplotlib/matplotlib/issues/25823 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7291679356b1b54719236e72d5daebc8aff16dc3118b051cbf56e112d99bc530/matplotlib/matplotlib/issues/25823 |
| og:image:alt | Bug summary When I execute python -c 'import matplotlib.pyplot', python will coredump. This will occur when it is generating the ~/.cache/matplotlib/fontlist-v330.json file, assuming that it was no... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | john-odonovan |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width