René's URL Explorer Experiment


Title: Receiver-consuming calls: an abandoned receiver leaks, a substituted one is over-released · Issue #571 · NativeScript/ios · GitHub

Open Graph Title: Receiver-consuming calls: an abandoned receiver leaks, a substituted one is over-released · Issue #571 · NativeScript/ios

X Title: Receiver-consuming calls: an abandoned receiver leaks, a substituted one is over-released · Issue #571 · NativeScript/ios

Description: Summary Initializers and NS_REPLACES_RECEIVER methods (-awakeAfterUsingCoder:) consume their receiver: the caller hands over its reference, and the method returns an owned object in its place, usually the receiver itself. The runtime get...

Open Graph Description: Summary Initializers and NS_REPLACES_RECEIVER methods (-awakeAfterUsingCoder:) consume their receiver: the caller hands over its reference, and the method returns an owned object in its place, usua...

X Description: Summary Initializers and NS_REPLACES_RECEIVER methods (-awakeAfterUsingCoder:) consume their receiver: the caller hands over its reference, and the method returns an owned object in its place, usua...

Opengraph URL: https://github.com/NativeScript/ios/issues/571

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Receiver-consuming calls: an abandoned receiver leaks, a substituted one is over-released","articleBody":"## Summary\n\nInitializers and `NS_REPLACES_RECEIVER` methods (`-awakeAfterUsingCoder:`) consume their receiver: the caller hands over its reference, and the method returns an owned object in its place, usually the receiver itself. The runtime gets the receiver's side of that contract wrong in two ways. #569 fixed the result side and lists both of these as not fixed.\n\n## 1. A JS initializer that returns something else leaks its receiver\n\nWhen a JS-implemented initializer returns a different object, or nil, the object allocated for the call is never released:\n\n```js\nconst X = NSObject.extend({\n  init() { return someOtherObject; }, // or: return null\n});\nX.new();           // the allocated receiver keeps its alloc +1\nnew X();           // same\nX.alloc().init();  // same\n```\n\nIn ObjC, `self = other; return self;` releases the original under ARC. A JS initializer has no way to, and `ArgConverter::MethodCallback` never releases the receiver either. It can't simply do so: when the JS initializer returns what `super.init…()` substituted, that super initializer already consumed the receiver, and releasing it again would free it under its wrapper. The two cases look the same from `MethodCallback`.\n\nA JS `-awakeAfterUsingCoder:` that returns another object leaves the caller's consumed reference behind in the same way.\n\nWith the wrapper lifetime work (#559 and up), the leftover retain reads as a native owner, so the abandoned receiver's wrapper stays a strong root.\n\n## 2. Consuming calls on a receiver that already existed\n\nFor a call from JS, the runtime passes the receiver without a reference for the callee to consume. That is fine while the method returns its receiver. When it doesn't:\n\n- **The receiver is over-released.** A native initializer that substitutes its receiver releases it, and the only reference there is belongs to the `Caches::Instances` entry. The wrapper is left pointing at an object that can be freed under it. This applies to re-initializing a wrapped object, to `super.init…()` inside a JS initializer, and to `Proto.initX.apply(this)`.\n- **A substitute that is already wrapped leaks a retain.** `Interop::ReleasesCachedOwnedReturn` never releases for a consumed receiver that existed before the call, because the usual result is the receiver itself, which carries no net +1. So when the result is a different, already wrapped object, its +1 stays. The likeliest case is `super.init…()` inside a JS initializer returning a cached singleton.\n\nReceivers allocated for the call (`X.alloc().init…()`, `new X()`) are not affected: there the alloc +1 is the reference the initializer consumes.\n\n## Suggested fix\n\n1. Before every receiver-consuming call from JS on a receiver that already existed, retain the receiver, so the callee has a reference to consume. Then every result of such a call is a real +1, whatever it is, and the cache-hit rule no longer needs its `Consumed` exception: release unless the result is not owned.\n2. For JS-implemented initializers, record on the call whether a consuming call was made on the receiver while the JS method ran (the `super.init…()` case). When the JS method returns something other than the receiver and no such call was made, release the receiver in `MethodCallback`.\n\nBoth parts change who owns the receiver across the JS boundary, so they need the same care as #569: exact counts for every caller and implementation, under AddressSanitizer.\n\n## Tests to add\n\n- A JS initializer returning another object, and one returning null, through `X.new()`, `new X()` and `X.alloc().init()`: the allocated receiver is freed exactly once.\n- A JS initializer returning the substitute of a super initializer: the receiver is freed exactly once and not twice (a fixture for a substituting initializer exists: `TNSSubstitutingInit`).\n- Re-initializing a wrapped object with a native initializer that substitutes it: the original is not freed while its wrapper is live, and the substitute's count is balanced when it is already wrapped.\n- `super.init…()` inside a JS initializer returning an already wrapped object: no retain is left on it.\n- A JS `-awakeAfterUsingCoder:` returning another object: the receiver's count is balanced.\n\nThese come from tracing the code paths for #569; the receiver leak in part 1 is also visible in that PR's specs, where the abandoned receiver is never freed.\n","author":{"url":"https://github.com/edusperoni","@type":"Person","name":"edusperoni"},"datePublished":"2026-11-15T16:12:08Z","url":"https://github.com/NativeScript/ios/issues/571"}

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:d7d55177-0f8f-a8fc-1122-07c238401b4e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB878:1D86C4:148BAD8:1A1DBFF:6B012B39
html-safe-noncec871ac633f50c8a2c14793ded0720e6f51515dcd3b2adc48f021fe2972dfe5fd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODc4OjFEODZDNDoxNDhCQUQ4OjFBMURCRkY6NkIwMTJCMzkiLCJ2aXNpdG9yX2lkIjoiMTU2MzUwMTY2MjQzMjIwOTcyMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6048649cda2b95490601c90f7baca018666e6758b50baa5ddc1b1fe1934c66aa
hovercard-subject-tagissue:6406314565
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/NativeScript/ios/571/issue_layout
twitter:imagehttps://opengraph.githubassets.com/475c01abcd59b7d979db2e743a2e76de7bd8687cb1a2c957002e311341556721/NativeScript/ios/issues/571
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/475c01abcd59b7d979db2e743a2e76de7bd8687cb1a2c957002e311341556721/NativeScript/ios/issues/571
og:image:altSummary Initializers and NS_REPLACES_RECEIVER methods (-awakeAfterUsingCoder:) consume their receiver: the caller hands over its reference, and the method returns an owned object in its place, usua...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameedusperoni
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/NativeScript/ios git https://github.com/NativeScript/ios.git
octolytics-dimension-user_id7392261
octolytics-dimension-user_loginNativeScript
octolytics-dimension-repository_id172934359
octolytics-dimension-repository_nwoNativeScript/ios
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id172934359
octolytics-dimension-repository_network_root_nwoNativeScript/ios
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/NativeScript/ios/issues/571#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fios%2Fissues%2F571
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%2FNativeScript%2Fios%2Fissues%2F571
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=NativeScript%2Fios
Reloadhttps://github.com/NativeScript/ios/issues/571
Reloadhttps://github.com/NativeScript/ios/issues/571
Reloadhttps://github.com/NativeScript/ios/issues/571
NativeScripthttps://github.com/NativeScript
ioshttps://github.com/NativeScript/ios
Codehttps://github.com/NativeScript/ios
Issues56 (56)https://github.com/NativeScript/ios/issues
Pull requests42 (42)https://github.com/NativeScript/ios/pulls
Actionshttps://github.com/NativeScript/ios/actions
Projectshttps://github.com/NativeScript/ios/projects
Security and qualityhttps://github.com/NativeScript/ios/security
Insightshttps://github.com/NativeScript/ios/insights
https://github.com/NativeScript/ios
New issuehttps://github.com/login?return_to=https://github.com/NativeScript/ios/issues/571
New issuehttps://github.com/login?return_to=https://github.com/NativeScript/ios/issues/571
Receiver-consuming calls: an abandoned receiver leaks, a substituted one is over-releasedhttps://github.com/NativeScript/ios/issues/571#top
https://github.com/edusperoni
edusperonihttps://github.com/edusperoni
on Nov 15, 2026https://github.com/NativeScript/ios/issues/571#issue-6406314565
#569https://github.com/NativeScript/ios/pull/569
#559https://github.com/NativeScript/ios/pull/559
#569https://github.com/NativeScript/ios/pull/569
#569https://github.com/NativeScript/ios/pull/569
Sign up for freehttps://github.com/signup?return_to=https://github.com/NativeScript/ios/issues/571
Sign in to commenthttps://github.com/login?return_to=https://github.com/NativeScript/ios/issues/571
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.