Title: gh-151763: Fix double decref in _PyPegen_raise_error_known_location() by manoj-marimuthu · Pull Request #151931 · python/cpython · GitHub
Open Graph Title: gh-151763: Fix double decref in _PyPegen_raise_error_known_location() by manoj-marimuthu · Pull Request #151931 · python/cpython
X Title: gh-151763: Fix double decref in _PyPegen_raise_error_known_location() by manoj-marimuthu · Pull Request #151931 · python/cpython
Description: The following PR addresses OOM-00019 from issue-151763. Issue: The _PyPegen_raise_error_known_location() in pegen_errors.c uses the Py_BuildValue function on a PyObject* called error_line with reference-stealing N format. tmp = Py_BuildValue("(OnnNnn)", p->tok->filename, lineno, col_number, error_line, end_lineno, end_col_number); when Py_BuildValue fails it returns NULL (ie tmp becomes NULL). when tmp == NULL, we do: if (!tmp) { goto error; } and goto error does: error: Py_XDECREF(errstr); Py_XDECREF(error_line); return NULL; This means that even if Py_BuildValue has decref'd error_line already, goto error repeats it which in turn trips _Py_NegativeRefcount: on debug builds. Reproduced using: import ast, _testcapi, faulthandler faulthandler.enable() src = "x y z\n" # generic invalid syntax -> located SyntaxError _testcapi.set_nomemory(55, 0) # fail every allocation from #55 onward try: ast.parse(src) # error_line built OK, then Py_BuildValue fails # -> N-arg already consumed -> error: decrefs it again finally: _testcapi.remove_mem_hooks() In debug build (tested on windows), it gives: _Py_NegativeRefcount: Assertion failed: object has negative ref count
Open Graph Description: The following PR addresses OOM-00019 from issue-151763. Issue: The _PyPegen_raise_error_known_location() in pegen_errors.c uses the Py_BuildValue function on a PyObject* called error_line with refe...
X Description: The following PR addresses OOM-00019 from issue-151763. Issue: The _PyPegen_raise_error_known_location() in pegen_errors.c uses the Py_BuildValue function on a PyObject* called error_line with refe...
Opengraph URL: https://github.com/python/cpython/pull/151931
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:25edb22e-ee50-8d76-bfaa-ae1c7c8e5ff4 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 901A:202447:4EC36:6D87A:6A535FAC |
| html-safe-nonce | aa77dd066190482e38334ab03af09c61645d5acbff3d7b9241040b30af6b7408 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDFBOjIwMjQ0Nzo0RUMzNjo2RDg3QTo2QTUzNUZBQyIsInZpc2l0b3JfaWQiOiIzODMzMDAzMDU0OTY3NTEzMDA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a6b5136544afb33a23e70bfb50ae09090565a03b361d2ec59bf9573152553f91 |
| hovercard-subject-tag | pull_request:3913829528 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/151931/files |
| twitter:image | https://avatars.githubusercontent.com/u/286359136?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/286359136?s=400&v=4 |
| og:image:alt | The following PR addresses OOM-00019 from issue-151763. Issue: The _PyPegen_raise_error_known_location() in pegen_errors.c uses the Py_BuildValue function on a PyObject* called error_line with refe... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width