Title: Change in OSX Catalina makes matplotlib + multiprocessing crash · Issue #15410 · matplotlib/matplotlib · GitHub
Open Graph Title: Change in OSX Catalina makes matplotlib + multiprocessing crash · Issue #15410 · matplotlib/matplotlib
X Title: Change in OSX Catalina makes matplotlib + multiprocessing crash · Issue #15410 · matplotlib/matplotlib
Description: I'm getting a crash on macOS Catalina when running some multiprocessing code after doing some plotting with matplotlib. Looks like this: libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Couldn't close file...
Open Graph Description: I'm getting a crash on macOS Catalina when running some multiprocessing code after doing some plotting with matplotlib. Looks like this: libc++abi.dylib: terminating with uncaught exception of type...
X Description: I'm getting a crash on macOS Catalina when running some multiprocessing code after doing some plotting with matplotlib. Looks like this: libc++abi.dylib: terminating with uncaught exception of ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/15410
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Change in OSX Catalina makes matplotlib + multiprocessing crash","articleBody":"I'm getting a crash on macOS Catalina when running some multiprocessing code after doing some plotting with matplotlib.\r\n\r\nLooks like this:\r\n```\r\nlibc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Couldn't close file\r\nFatal Python error: Aborted\r\n```\r\nand using `print(psutil.Process().open_files())` I figured out that likely the issue is that this MPL TTF font file is opened multiple times and (I guess) for some reason closing the file occurs only later, from my multiprocessing code, and that fails on macOS Catalina.\r\n```\r\nopen files: [popenfile(path='/Users/deil/anaconda3/envs/gammapy-dev/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans.ttf', fd=5), popenfile(path='/Users/deil/anaconda3/envs/gammapy-dev/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans.ttf', fd=6), popenfile(path='/Users/deil/anaconda3/envs/gammapy-dev/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf', fd=7), popenfile(path='/Users/deil/anaconda3/envs/gammapy-dev/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf', fd=8)]\r\n```\r\n\r\nI tried to extract a minimal test case that doesn't involve our software, but couldn't so far, sorry.\r\nBut you should be able to reproduce the crash by copy \u0026 pasting these commands:\r\n```\r\ngit clone https://github.com/gammapy/gammapy.git\r\ncd gammapy\r\nconda env create -f environment-dev.yml\r\npip install -e .\r\npytest -s -v gammapy/cube\r\n```\r\nLog: https://gist.github.com/cdeil/a75211856a3bcab751ead707df9708c9#file-gistfile1-txt-L88\r\n\r\nI know MPL isn't thread-safe. But it should be possible to do some plotting, and then later after plotting is done to run some multiprocessing code, no?\r\n\r\nIs it normal that the file handle for `DejaVuSansDisplay.ttf` remains open?\r\nShouldn't MPL load the file content and close the file handle directly?\r\nMaybe that is a bug?\r\n\r\nI don't think it matters for this issue, but in case it does -- we are calling `plt.close()` after all plotting from our tests, because previously we had a problem with too many open figures (see [here](\r\nhttps://github.com/gammapy/gammapy/blob/d4db11d559b210c0e0d03bba75ddcff9c03e0511/gammapy/utils/testing.py#L209-L230\r\n\r\n```\r\n(gammapy-dev) hfm-1804a:gammapy deil$ python --version\r\nPython 3.7.0\r\n(gammapy-dev) hfm-1804a:gammapy deil$ python -c 'import matplotlib; print(matplotlib.__version__)'\r\n3.1.1\r\n(gammapy-dev) hfm-1804a:gammapy deil$ python -c 'import matplotlib; print(matplotlib.get_backend())'\r\nMacOSX\r\n```","author":{"url":"https://github.com/cdeil","@type":"Person","name":"cdeil"},"datePublished":"2019-10-12T09:49:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":38},"url":"https://github.com/15410/matplotlib/issues/15410"}
| 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:13282003-77bc-d7c7-1f5f-b25e8c15032f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A3F4:26AD97:E8EDFE:1385E6C:6A52916E |
| html-safe-nonce | f628d91e9c961c5911d87f75c1514462cc85f361f6c15920d38f5f1758d3cbe1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0Y0OjI2QUQ5NzpFOEVERkU6MTM4NUU2Qzo2QTUyOTE2RSIsInZpc2l0b3JfaWQiOiI2MTY4NTA1NDI0NzAwMTUwMTI2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 52dd21c63b0907be46d220cc374d119cc1dcb76f9269de4a629d66eff00adede |
| hovercard-subject-tag | issue:506163599 |
| 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/15410/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a27e7dc4c8b56c13d209544ad8dc0077e6d6cf7eb0703bae0acbcfb7b308050c/matplotlib/matplotlib/issues/15410 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a27e7dc4c8b56c13d209544ad8dc0077e6d6cf7eb0703bae0acbcfb7b308050c/matplotlib/matplotlib/issues/15410 |
| og:image:alt | I'm getting a crash on macOS Catalina when running some multiprocessing code after doing some plotting with matplotlib. Looks like this: libc++abi.dylib: terminating with uncaught exception of type... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cdeil |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width