Title: TypeManager.pointer_attribute cannot be safely used in nested CustomType. · Issue #480 · Source-Python-Dev-Team/Source.Python · GitHub
Open Graph Title: TypeManager.pointer_attribute cannot be safely used in nested CustomType. · Issue #480 · Source-Python-Dev-Team/Source.Python
X Title: TypeManager.pointer_attribute cannot be safely used in nested CustomType. · Issue #480 · Source-Python-Dev-Team/Source.Python
Description: This is partially related to #472 and #474 though. The values set in the TypeManager.pointer_attribute are managed by CustomType._allocated_pointers or CustomType._pointer_values, but if the original CustomType is managed by another obje...
Open Graph Description: This is partially related to #472 and #474 though. The values set in the TypeManager.pointer_attribute are managed by CustomType._allocated_pointers or CustomType._pointer_values, but if the origin...
X Description: This is partially related to #472 and #474 though. The values set in the TypeManager.pointer_attribute are managed by CustomType._allocated_pointers or CustomType._pointer_values, but if the origin...
Opengraph URL: https://github.com/Source-Python-Dev-Team/Source.Python/issues/480
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TypeManager.pointer_attribute cannot be safely used in nested CustomType.","articleBody":"This is partially related to #472 and #474 though.\r\n\r\nThe values set in the `TypeManager.pointer_attribute` are managed by `CustomType._allocated_pointers` or `CustomType._pointer_values`, but if the original CustomType is managed by another object, they will be deallocated instantly. This means that pointer manipulation is not possible on nested CustomTypes.\r\n\r\nMy advice is we should stop using `TypeManager.pointer_attribute`. This feature has not been tested for a long time(#391) and should only be used in situations where you have full control over the memory of the values you are setting. (i.e. only non-native_type that you can manage yourself.) I found this out the hard way.\r\n\r\n```python\r\nfrom memory.manager import CustomType\r\nfrom memory.manager import TypeManager\r\n\r\nmanager = TypeManager()\r\n\r\nclass Test(CustomType, metaclass=manager):\r\n _size = 12\r\n\r\n test2 = manager.instance_attribute(\"Test2\", 4)\r\n\r\nclass Test2(CustomType, metaclass=manager):\r\n _size = 8\r\n size = manager.pointer_attribute(Type.INT, 0)\r\n other_test = manager.pointer_attribute(\"Test\", 4)\r\n\r\ntest = Test()\r\ntest.test2.size = 1 # BROKEN!, the memory of size is already deallocated.\r\ntest.test2.other_test = Test() # BROKEN!, the memory of Test is already deallocated.\r\n```","author":{"url":"https://github.com/CookStar","@type":"Person","name":"CookStar"},"datePublished":"2023-06-28T14:14:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/480/Source.Python/issues/480"}
| 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:156c61c5-1255-fffc-6cde-52341237a883 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EDD8:3891C0:25446CF:31E9289:697067FC |
| html-safe-nonce | b580f42d760c241b817f8235cb549e1854d962fce8de0a46d20b31f831fd6cc7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREQ4OjM4OTFDMDoyNTQ0NkNGOjMxRTkyODk6Njk3MDY3RkMiLCJ2aXNpdG9yX2lkIjoiMTMyNDMwMzQ0NDY1NDE4ODU0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2f078c0a03f14025aa940cac43a1e92fe8575cb8959828b21143b240dfe65269 |
| hovercard-subject-tag | issue:1779047747 |
| 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/Source-Python-Dev-Team/Source.Python/480/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f9ca2ae76ff8b0cbab7e84337301a1905c0f900bd2a12d9039e0f122cf09cfbf/Source-Python-Dev-Team/Source.Python/issues/480 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f9ca2ae76ff8b0cbab7e84337301a1905c0f900bd2a12d9039e0f122cf09cfbf/Source-Python-Dev-Team/Source.Python/issues/480 |
| og:image:alt | This is partially related to #472 and #474 though. The values set in the TypeManager.pointer_attribute are managed by CustomType._allocated_pointers or CustomType._pointer_values, but if the origin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | CookStar |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/Source-Python-Dev-Team/Source.Python git https://github.com/Source-Python-Dev-Team/Source.Python.git |
| octolytics-dimension-user_id | 5440368 |
| octolytics-dimension-user_login | Source-Python-Dev-Team |
| octolytics-dimension-repository_id | 12771934 |
| octolytics-dimension-repository_nwo | Source-Python-Dev-Team/Source.Python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 12771934 |
| octolytics-dimension-repository_network_root_nwo | Source-Python-Dev-Team/Source.Python |
| 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 | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width