René's URL Explorer Experiment


Title: `_csv.reader`: NULL deref via re-entrant iterator · Issue #145105 · python/cpython · GitHub

Open Graph Title: `_csv.reader`: NULL deref via re-entrant iterator · Issue #145105 · python/cpython

X Title: `_csv.reader`: NULL deref via re-entrant iterator · Issue #145105 · python/cpython

Description: Bug report Bug description: A NULL pointer dereference in Modules/_csv.c causes a segfault when a custom iterator re-enters the same csv.reader from within its __next__ method. The inner iteration sets self->fields to NULL, the outer ite...

Open Graph Description: Bug report Bug description: A NULL pointer dereference in Modules/_csv.c causes a segfault when a custom iterator re-enters the same csv.reader from within its __next__ method. The inner iteration ...

X Description: Bug report Bug description: A NULL pointer dereference in Modules/_csv.c causes a segfault when a custom iterator re-enters the same csv.reader from within its __next__ method. The inner iteration ...

Opengraph URL: https://github.com/python/cpython/issues/145105

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`_csv.reader`: NULL deref via re-entrant iterator","articleBody":"# Bug report\n\n### Bug description:\n\nA NULL pointer dereference in `Modules/_csv.c` causes a segfault when a\ncustom iterator re-enters the same `csv.reader` from within its `__next__`\nmethod. The inner iteration sets `self-\u003efields` to `NULL`, the outer\niteration then passes that `NULL` to `PyList_Append`, crashing the\ninterpreter.\n\n```python\nimport _csv\n\n\nclass BadIterator:\n    def __init__(self):\n        self.reader = None\n        self.n = 0\n\n    def __iter__(self):\n        return self\n\n    def __next__(self):\n        self.n += 1\n        if self.n == 1:\n            try:\n                next(self.reader)\n            except StopIteration:\n                pass\n            return \"a,b\"\n        if self.n == 2:\n            return \"x\"\n        raise StopIteration\n\n\nit = BadIterator()\nr = _csv.reader(it)\nit.reader = r\nnext(r)\n```\n\n```C\n\n❯ ./build-asan/python csv_null_deref.py\nAddressSanitizer:DEADLYSIGNAL\n=================================================================\n==293160==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x5dc88a0b1c52 bp 0x7ffdd3075180 sp 0x7ffdd3075170 T0)\n==293160==The signal is caused by a READ memory access.\n==293160==Hint: address points to the zero page.\n    #0 0x5dc88a0b1c52 in _Py_TYPE_impl ../Include/object.h:313\n    #1 0x5dc88a0b1c52 in PyList_Append ../Objects/listobject.c:541\n    #2 0x7ea5a8430ad5 in parse_save_field ../Modules/_csv.c:684\n    #3 0x7ea5a843129b in parse_process_char ../Modules/_csv.c:811\n    #4 0x7ea5a8431967 in Reader_iternext_lock_held ../Modules/_csv.c:971\n    #5 0x7ea5a8431bdf in Reader_iternext ../Modules/_csv.c:993\n    #6 0x5dc88a2b0820 in builtin_next ../Python/bltinmodule.c:1756\n    #7 0x5dc88a0fb36f in cfunction_vectorcall_FASTCALL ../Objects/methodobject.c:449\n    #8 0x5dc88a043ccc in _PyObject_VectorcallTstate ../Include/internal/pycore_call.h:136\n    #9 0x5dc88a043dbf in PyObject_Vectorcall ../Objects/call.c:327\n    #10 0x5dc88a2c28b7 in _Py_VectorCallInstrumentation_StackRefSteal ../Python/ceval.c:769\n    #11 0x5dc88a2d287b in _PyEval_EvalFrameDefault ../Python/generated_cases.c.h:1817\n    #12 0x5dc88a309ab0 in _PyEval_EvalFrame ../Include/internal/pycore_ceval.h:118\n    #13 0x5dc88a309e16 in _PyEval_Vector ../Python/ceval.c:2132\n    #14 0x5dc88a30a0cc in PyEval_EvalCode ../Python/ceval.c:680\n    #15 0x5dc88a40d771 in run_eval_code_obj ../Python/pythonrun.c:1366\n    #16 0x5dc88a40dab7 in run_mod ../Python/pythonrun.c:1469\n    #17 0x5dc88a40e9ec in pyrun_file ../Python/pythonrun.c:1294\n    #18 0x5dc88a411822 in _PyRun_SimpleFileObject ../Python/pythonrun.c:518\n    #19 0x5dc88a411ace in _PyRun_AnyFileObject ../Python/pythonrun.c:81\n    #20 0x5dc88a466df6 in pymain_run_file_obj ../Modules/main.c:410\n    #21 0x5dc88a467063 in pymain_run_file ../Modules/main.c:429\n    #22 0x5dc88a468861 in pymain_run_python ../Modules/main.c:691\n    #23 0x5dc88a468ef7 in Py_RunMain ../Modules/main.c:772\n    #24 0x5dc88a4690e3 in pymain_main ../Modules/main.c:802\n    #25 0x5dc88a469468 in Py_BytesMain ../Modules/main.c:826\n    #26 0x5dc889ece675 in main ../Programs/python.c:15\n    #27 0x7ea5a822a3b7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58\n    #28 0x7ea5a822a47a in __libc_start_main_impl ../csu/libc-start.c:360\n    #29 0x5dc889ece5a4 in _start (/home/raminfp/Projects/cpython/build-asan/python+0x2ee5a4) (BuildId: 84c80339980a79597ee91e337ac316189316df7c)\n\nAddressSanitizer can not provide additional info.\nSUMMARY: AddressSanitizer: SEGV ../Include/object.h:313 in _Py_TYPE_impl\n==293160==ABORTING\n```\n\n### GDB\n\n```bash\ngdb -batch \\\n  -ex \"run csv_null_deref.py\" \\\n  -ex \"frame 2\" -ex \"print self-\u003efields\" -ex \"print self-\u003estate\" \\\n  -ex \"frame 3\" -ex \"print c\" \\\n  -ex \"frame 1\" -ex \"print op\" \\\n  ./build-asan/python\n```\n\n```bash\nProgram received signal SIGSEGV, Segmentation fault.\n0x0000555555a25c52 in _Py_TYPE_impl (ob=0x0) at ../Include/object.h:313\n313\t    return ob-\u003eob_type;\n#2  0x00007ffff762dad6 in parse_save_field (self=self@entry=0x50c00000c8a0) at ../Modules/_csv.c:684\n684\t    if (PyList_Append(self-\u003efields, field) \u003c 0) {\n$1 = (PyObject *) 0x0\n$2 = IN_FIELD\n#3  0x00007ffff762e29c in parse_process_char (self=self@entry=0x50c00000c8a0, module_state=module_state@entry=0x507000112680, c=44) at ../Modules/_csv.c:811\n811\t            if (parse_save_field(self) \u003c 0)\n$3 = 44\n#1  PyList_Append (op=0x0, newitem=newitem@entry=0x555556527048 \u003c_PyRuntime+125736\u003e) at ../Objects/listobject.c:541\n541\t    if (PyList_Check(op) \u0026\u0026 (newitem != NULL)) {\n$4 = (PyObject *) 0x0\n\n````\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-145106\n* gh-148404\n* gh-148405\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/raminfp","@type":"Person","name":"raminfp"},"datePublished":"2026-02-22T11:12:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/145105/cpython/issues/145105"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:3439dbc1-3f12-615b-b75c-c8cc8b1076bf
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCB70:3F08AB:763FC:A0C47:6A5FB599
html-safe-nonce99886df472f431b538f038c838b00361a835f122d7195c0a3a2e1639f9ffae75
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjcwOjNGMDhBQjo3NjNGQzpBMEM0Nzo2QTVGQjU5OSIsInZpc2l0b3JfaWQiOiI4MzAxODg0NTYzMzA5NzA0NjAxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac2a8a73f8ca72778f7f5cf74feabec30314069fb3eecf76561465f9bf350b2eb5
hovercard-subject-tagissue:3974236447
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/python/cpython/145105/issue_layout
twitter:imagehttps://opengraph.githubassets.com/bf89546e4664deef07683198bd1d0b7dfa10130aa93c9771e4ce09c528331652/python/cpython/issues/145105
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/bf89546e4664deef07683198bd1d0b7dfa10130aa93c9771e4ce09c528331652/python/cpython/issues/145105
og:image:altBug report Bug description: A NULL pointer dereference in Modules/_csv.c causes a segfault when a custom iterator re-enters the same csv.reader from within its __next__ method. The inner iteration ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameraminfp
hostnamegithub.com
expected-hostnamegithub.com
Nonee0cfc367faf9c4c774d2a903897aa214c786247c4f45ffcee48cda2b819fb0c8
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
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
release94569c859bc88d6bf7de7e0ce3f2a11cd529a131
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/145105#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F145105
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
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
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%2Fpython%2Fcpython%2Fissues%2F145105
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=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/145105
Reloadhttps://github.com/python/cpython/issues/145105
Reloadhttps://github.com/python/cpython/issues/145105
Please reload this pagehttps://github.com/python/cpython/issues/145105
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/145105
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.4k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
_csv.reader: NULL deref via re-entrant iteratorhttps://github.com/python/cpython/issues/145105#top
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/raminfp
raminfphttps://github.com/raminfp
on Feb 22, 2026https://github.com/python/cpython/issues/145105#issue-3974236447
gh-145105: Fix crash in csv.reader with re-entrant iterator #145106https://github.com/python/cpython/pull/145106
[3.14] gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106) #148404https://github.com/python/cpython/pull/148404
[3.13] gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106) #148405https://github.com/python/cpython/pull/148405
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%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.