Title: `this.super` keeps a raw pointer to the receiver's wrapper and can outlive it · Issue #568 · NativeScript/ios · GitHub
Open Graph Title: `this.super` keeps a raw pointer to the receiver's wrapper and can outlive it · Issue #568 · NativeScript/ios
X Title: `this.super` keeps a raw pointer to the receiver's wrapper and can outlive it · Issue #568 · NativeScript/ios
Description: Summary this.super on an .extend() class returns a new object on every access (ClassBuilder::SuperAccessorGetterCallback). Its internal field is a copy of the receiver's: the External that holds the receiver's ObjCDataWrapper*. The alias...
Open Graph Description: Summary this.super on an .extend() class returns a new object on every access (ClassBuilder::SuperAccessorGetterCallback). Its internal field is a copy of the receiver's: the External that holds th...
X Description: Summary this.super on an .extend() class returns a new object on every access (ClassBuilder::SuperAccessorGetterCallback). Its internal field is a copy of the receiver's: the External that hold...
Opengraph URL: https://github.com/NativeScript/ios/issues/568
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`this.super` keeps a raw pointer to the receiver's wrapper and can outlive it","articleBody":"## Summary\n\n`this.super` on an `.extend()` class returns a new object on every access (`ClassBuilder::SuperAccessorGetterCallback`). Its internal field is a copy of the receiver's: the `External` that holds the receiver's `ObjCDataWrapper*`. The alias does not keep the receiver alive, and nothing tells it when that wrapper is deleted.\n\nIf JS keeps the alias longer than the receiver's wrapper lives, a call through it reads a deleted wrapper.\n\n## How the wrapper goes away under a live alias\n\n1. **The receiver is collected.** The alias holds no reference to it:\n\n ```js\n let s = obj.super;\n obj = null;\n // after a collection, obj's finalizer deletes the wrapper\n s.description; // reads the deleted wrapper\n ```\n\n `ObjectManager::DisposeValue` skips the alias itself (\"Do not dispose the ObjCWrapper contained in a super instance\"), so the alias survives with the stale pointer.\n2. **`__releaseNativeCounterpart(obj)`** deletes the wrapper right away, with the same result for an alias taken earlier.\n3. **A JS method run by `-dealloc`** (after #564). The receiver gets a borrowed wrapper that is detached and deleted when the call returns. `this` then reads as released, but an alias saved from that call still points at the deleted wrapper:\n\n ```js\n const Keeper = TNSApi.extend({\n methodCalledInDealloc() { saved = this.super; },\n });\n ```\n\n Before #564 the wrapper stayed in this case but the object was already freed, so the alias was unsafe there too.\n\n## Suggested fix\n\nThe alias should find the wrapper through its receiver when it is used, not copy the pointer when it is created. For example, it can hold the receiver and have the wrapper lookup follow it. Then:\n\n- a receiver that was released or detached reads as released through the alias, with the existing released-object error;\n- the alias keeps its receiver alive for as long as JS can reach the alias.\n\n## Tests to add\n\n- An alias taken from a live object, used after the object's wrapper is released with `__releaseNativeCounterpart`: it reports the object as released.\n- An alias kept after its receiver is dropped and several collections ran: it still works (the receiver is kept alive) or reports released, but never touches freed memory. Run under AddressSanitizer.\n- An alias saved from a JS method run by `-dealloc`: it reports released.\n\nFound by reading the code paths; not reproduced yet.\n","author":{"url":"https://github.com/edusperoni","@type":"Person","name":"edusperoni"},"datePublished":"2026-11-14T18:30:27Z","url":"https://github.com/NativeScript/ios/issues/568"}
| 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:f970ed2b-fc38-5796-9c71-127fb809219f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8052:1F65:D3DDB4:10CAD2A:6B015BC8 |
| html-safe-nonce | c921fc9a192fb03284ac0f22399254e2eefd797e8238b53e609d6f8316adbab2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDUyOjFGNjU6RDNEREI0OjEwQ0FEMkE6NkIwMTVCQzgiLCJ2aXNpdG9yX2lkIjoiNzgwNTA4NTg0MjIyMDg2NjUwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d392a53ba18e08c220f8a452077e0d979887538391c67c57f57d6cafa95c6c62 |
| hovercard-subject-tag | issue:6394289951 |
| 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/NativeScript/ios/568/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ea77884175bd5015e89aa876d6f6e766a9a41478f1454103a9aa40a752a1de7b/NativeScript/ios/issues/568 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ea77884175bd5015e89aa876d6f6e766a9a41478f1454103a9aa40a752a1de7b/NativeScript/ios/issues/568 |
| og:image:alt | Summary this.super on an .extend() class returns a new object on every access (ClassBuilder::SuperAccessorGetterCallback). Its internal field is a copy of the receiver's: the External that holds th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | edusperoni |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/ios git https://github.com/NativeScript/ios.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 172934359 |
| octolytics-dimension-repository_nwo | NativeScript/ios |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 172934359 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/ios |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width