Title: Multiple reference leaks in `curses` error-branches · Issue #123290 · python/cpython · GitHub
Open Graph Title: Multiple reference leaks in `curses` error-branches · Issue #123290 · python/cpython
X Title: Multiple reference leaks in `curses` error-branches · Issue #123290 · python/cpython
Description: Bug report Bug description: In _cursesmodule.c, we have #define SetDictInt(string,ch) \ do { \ PyObject *o = PyLong_FromLong((long) (ch)); \ if (o && PyDict_SetItemString(ModDict, string, o) == 0) { \ Py_DECREF(o); \ } \ } while (0) Howe...
Open Graph Description: Bug report Bug description: In _cursesmodule.c, we have #define SetDictInt(string,ch) \ do { \ PyObject *o = PyLong_FromLong((long) (ch)); \ if (o && PyDict_SetItemString(ModDict, string, o) == 0) ...
X Description: Bug report Bug description: In _cursesmodule.c, we have #define SetDictInt(string,ch) \ do { \ PyObject *o = PyLong_FromLong((long) (ch)); \ if (o && PyDict_SetItemString(ModDict, string, o...
Opengraph URL: https://github.com/python/cpython/issues/123290
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Multiple reference leaks in `curses` error-branches ","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nIn `_cursesmodule.c`, we have \r\n\r\n```C\r\n#define SetDictInt(string,ch) \\\r\n do { \\\r\n PyObject *o = PyLong_FromLong((long) (ch)); \\\r\n if (o && PyDict_SetItemString(ModDict, string, o) == 0) { \\\r\n Py_DECREF(o); \\\r\n } \\\r\n } while (0)\r\n```\r\n\r\nHowever, `PyDict_SetItemString` does not steal a reference. If the dict insertion fails for whatever reason, `o` must be decref, which is not the case here. Similarly, in `PyInit__curses`, a module object is explicitly created via `PyModule_Create` but is not decref if an error occurs: https://github.com/python/cpython/blob/b178beef269409d089caa429bd9261cf7283b55e/Modules/_cursesmodule.c#L4766\r\n\r\nThere are also calls that are not checked against errors:\r\n\r\nhttps://github.com/python/cpython/blob/b178beef269409d089caa429bd9261cf7283b55e/Modules/_cursesmodule.c#L4808-L4811\r\n\r\nHere, insertion is assumed to always succeed, but this may not be the case, in which case we shouldn't continue.\r\n\r\nOn the other hand, the `PyCursesWindowType` leaks since it's never cleared. While it does not matter if you exit the interpreter, I think it may matter if you just want to unload the module and continue with a normal execution.\r\n\r\n----\r\n\r\nThere are also other bugs that are more generally related to error-handling where some pointers might be NULL but are used as if they were not NULL, e.g. #123913).\r\n\r\n### CPython versions tested on:\r\n\r\nCPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\r\n\r\n\u003c!-- gh-linked-prs -->\r\n### Linked PRs\r\n* gh-123910\r\n* gh-123953\n* gh-124767\n\u003c!-- /gh-linked-prs -->\r\n","author":{"url":"https://github.com/picnixz","@type":"Person","name":"picnixz"},"datePublished":"2024-08-24T13:18:49Z","url":"https://github.com/python/cpython/issues/123290"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:4100c687-84c4-0e4e-ff32-49657954bd1b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 89CA:3A79D:219E1:2B8E1:6B06612F |
| html-safe-nonce | 05e4daa3ff472740c96b2d40a00af8e1251dc45b98e3c1a0cabc2b39d3b1bdc5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OUNBOjNBNzlEOjIxOUUxOjJCOEUxOjZCMDY2MTJGIiwidmlzaXRvcl9pZCI6IjQ4NTAyMTgzMjA0NzUzNDkyOTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 977bf77b95c2496994d6dbfbb74785e794510807550814513cd62175961bb229 |
| hovercard-subject-tag | issue:2484587837 |
| 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/python/cpython/123290/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7011166a6c8d6346a99da6aaefe23a5a598ff562338b9152a2fc6944110e32d0/python/cpython/issues/123290 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7011166a6c8d6346a99da6aaefe23a5a598ff562338b9152a2fc6944110e32d0/python/cpython/issues/123290 |
| og:image:alt | Bug report Bug description: In _cursesmodule.c, we have #define SetDictInt(string,ch) \ do { \ PyObject *o = PyLong_FromLong((long) (ch)); \ if (o && PyDict_SetItemString(ModDict, string, o) == 0) ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | picnixz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6324e6ac990fb6befbec840cc0e102a1071c339bfe8f9826bb12de2e3ba1d297 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | 7f0aa75f4141d440c6110dc31af7ea7797abb6c4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width