René's URL Explorer Experiment


Title: robustness: cache mutates shared `DNSRecord` instances in place to expire TTL · Issue #1780 · python-zeroconf/python-zeroconf · GitHub

Open Graph Title: robustness: cache mutates shared `DNSRecord` instances in place to expire TTL · Issue #1780 · python-zeroconf/python-zeroconf

X Title: robustness: cache mutates shared `DNSRecord` instances in place to expire TTL · Issue #1780 · python-zeroconf/python-zeroconf

Description: Problem async_mark_unique_records_older_than_1s_to_expire walks the cache and calls _async_set_created_ttl(record, now, 1), which mutates record.created and record.ttl in place via record._set_created_ttl(...), then re-_async_adds the sa...

Open Graph Description: Problem async_mark_unique_records_older_than_1s_to_expire walks the cache and calls _async_set_created_ttl(record, now, 1), which mutates record.created and record.ttl in place via record._set_crea...

X Description: Problem async_mark_unique_records_older_than_1s_to_expire walks the cache and calls _async_set_created_ttl(record, now, 1), which mutates record.created and record.ttl in place via record._set_crea...

Opengraph URL: https://github.com/python-zeroconf/python-zeroconf/issues/1780

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"robustness: cache mutates shared `DNSRecord` instances in place to expire TTL","articleBody":"## Problem\n\n`async_mark_unique_records_older_than_1s_to_expire` walks the cache and calls `_async_set_created_ttl(record, now, 1)`, which mutates `record.created` and `record.ttl` in place via `record._set_created_ttl(...)`, then re-`_async_add`s the same object. The code itself flags this — line 345 says \"It would be better if we made a copy instead of mutating the record in place, but records currently don't have a copy method.\" Listeners (`RecordUpdate.old` references obtained from `cache.async_get_unique` elsewhere in the same dispatch tick), `ServiceInfo` instances holding references to cached records, and anything in `_handlers/multicast_outgoing_queue.AnswerGroup.answers` that keys on a `DNSAddress`/`DNSPointer` instance will silently see their TTL/created flip to the new values mid-dispatch. The RFC-mandated \"expire in 1s\" path (RFC 6762 §10.2) is therefore not isolated from in-flight consumers.\n\n## Why This Matters\n\nSubtle correctness drift in hot path: any code path that captured a `DNSRecord` reference and decided \"this record is fresh, use it\" can have the same object turn stale between two of its own lines. It's also hostile to free-threading (3.14t) — concurrent reads of `record.created` / `record.ttl` while another thread is in the middle of `_set_created_ttl` are an unsynchronized write race.\n\n## Suggested Fix\n\nAdd a `copy_with_ttl(now, ttl)` (or `_cdef`-typed `_clone_with_created_ttl`) method on `DNSRecord` (and update the `.pxd` so the new method is visible on the cython hot path), then in `_async_set_created_ttl` replace the in-place mutation with `replacement = record.copy_with_ttl(now, 1); self._async_add(replacement)`. The old record will fall out of the cache when the new one supersedes it via `async_add_records`. Update the comment to remove the \"It would be better\" footnote once done.\n\n## Details\n\n| | |\n|---|---|\n| **Severity** | 🟡 Medium |\n| **Category** | robustness |\n| **Location** | `src/zeroconf/_cache.py:325-348` |\n| **Effort** | 🛠️ Moderate effort |\n\n---\n🤖 Created by Kōan from audit session\n\u003c!-- koan-audit-id: 56e459653dc4af71 -->","author":{"url":"https://github.com/bluetoothbot","@type":"Person","name":"bluetoothbot"},"datePublished":"2026-05-26T16:28:16Z","url":"https://github.com/python-zeroconf/python-zeroconf/issues/1780"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4f564103-60c5-36b9-f729-dd8aeed0f0da
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE30C:2BEA87:F7BB:15A78:6B007D35
html-safe-nonce7b7c13c58a1c365e1d49feaaa0dba83404d8647eeae3102e74971ce56fc05ca9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzBDOjJCRUE4NzpGN0JCOjE1QTc4OjZCMDA3RDM1IiwidmlzaXRvcl9pZCI6IjExNzE0MzM0NTUzOTc5MjgyNDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac6e74780a4f74e81224b610784404d64222b7df938a1f79663ecb227e4e26d547
hovercard-subject-tagissue:4525792883
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-zeroconf/python-zeroconf/1780/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f5a6380f27a8293080f37ee3a010bde9b595405f1bcb2ecefc8ce5eabacb9188/python-zeroconf/python-zeroconf/issues/1780
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f5a6380f27a8293080f37ee3a010bde9b595405f1bcb2ecefc8ce5eabacb9188/python-zeroconf/python-zeroconf/issues/1780
og:image:altProblem async_mark_unique_records_older_than_1s_to_expire walks the cache and calls _async_set_created_ttl(record, now, 1), which mutates record.created and record.ttl in place via record._set_crea...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebluetoothbot
hostnamegithub.com
expected-hostnamegithub.com
None82c186f13e104004ab7bdb779f3195e59dd38bfde531aaa74b76470fc2462b83
turbo-cache-controlno-preview
go-importgithub.com/python-zeroconf/python-zeroconf git https://github.com/python-zeroconf/python-zeroconf.git
octolytics-dimension-user_id120192235
octolytics-dimension-user_loginpython-zeroconf
octolytics-dimension-repository_id21548731
octolytics-dimension-repository_nwopython-zeroconf/python-zeroconf
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id21548731
octolytics-dimension-repository_network_root_nwopython-zeroconf/python-zeroconf
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
released1bc2aa1939001689f5ce935982c10a6138f745c
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python-zeroconf/python-zeroconf/issues/1780#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-zeroconf%2Fpython-zeroconf%2Fissues%2F1780
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-zeroconf%2Fpython-zeroconf%2Fissues%2F1780
Sign uphttps://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-zeroconf%2Fpython-zeroconf
Reloadhttps://github.com/python-zeroconf/python-zeroconf/issues/1780
Reloadhttps://github.com/python-zeroconf/python-zeroconf/issues/1780
Reloadhttps://github.com/python-zeroconf/python-zeroconf/issues/1780
python-zeroconfhttps://github.com/python-zeroconf
python-zeroconfhttps://github.com/python-zeroconf/python-zeroconf
Codehttps://github.com/python-zeroconf/python-zeroconf
Issues50 (50)https://github.com/python-zeroconf/python-zeroconf/issues
Pull requests16 (16)https://github.com/python-zeroconf/python-zeroconf/pulls
Discussionshttps://github.com/python-zeroconf/python-zeroconf/discussions
Actionshttps://github.com/python-zeroconf/python-zeroconf/actions
Projectshttps://github.com/python-zeroconf/python-zeroconf/projects
Wikihttps://github.com/python-zeroconf/python-zeroconf/wiki
Security and quality5 (5)https://github.com/python-zeroconf/python-zeroconf/security
Insightshttps://github.com/python-zeroconf/python-zeroconf/insights
https://github.com/python-zeroconf/python-zeroconf
New issuehttps://github.com/login?return_to=https://github.com/python-zeroconf/python-zeroconf/issues/1780
New issuehttps://github.com/login?return_to=https://github.com/python-zeroconf/python-zeroconf/issues/1780
robustness: cache mutates shared DNSRecord instances in place to expire TTLhttps://github.com/python-zeroconf/python-zeroconf/issues/1780#top
https://github.com/bluetoothbot
bluetoothbothttps://github.com/bluetoothbot
on May 26, 2026https://github.com/python-zeroconf/python-zeroconf/issues/1780#issue-4525792883
https://github.com/bdraco
bdracohttps://github.com/bdraco
on May 26, 2026https://github.com/python-zeroconf/python-zeroconf/issues/1780#issuecomment-4546291460
https://github.com/bdraco
bdracohttps://github.com/bdraco
on May 26, 2026https://github.com/python-zeroconf/python-zeroconf/issues/1780#issuecomment-4546293708
@bluetoothbothttps://github.com/bluetoothbot
bdracohttps://github.com/bdraco
on Jun 3, 2026https://github.com/python-zeroconf/python-zeroconf/issues/1780#event-26287992437
test: add benchmarks for cache mark-to-expire path (#1780) (#1785)https://github.com/python-zeroconf/python-zeroconf/commit/29cc405045947bf121405cfbc3dbb08805a4c160
#1780https://github.com/python-zeroconf/python-zeroconf/issues/1780
#1785https://github.com/python-zeroconf/python-zeroconf/pull/1785
29cc405https://github.com/python-zeroconf/python-zeroconf/commit/29cc405045947bf121405cfbc3dbb08805a4c160
Sign up for freehttps://github.com/signup?return_to=https://github.com/python-zeroconf/python-zeroconf/issues/1780
Sign in to commenthttps://github.com/login?return_to=https://github.com/python-zeroconf/python-zeroconf/issues/1780
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.