René's URL Explorer Experiment


Title: Leaked memory in `IfcPropertySingleValue.NominalValue` with a newly allocated `IfcValue` · Issue #8070 · IfcOpenShell/IfcOpenShell · GitHub

Open Graph Title: Leaked memory in `IfcPropertySingleValue.NominalValue` with a newly allocated `IfcValue` · Issue #8070 · IfcOpenShell/IfcOpenShell

X Title: Leaked memory in `IfcPropertySingleValue.NominalValue` with a newly allocated `IfcValue` · Issue #8070 · IfcOpenShell/IfcOpenShell

Description: Bug Description setNominalValue() stores the new pointer in the property through set_attribute_value() 1 2, but the new value is not clearly owned by IfcFile. Later, when IfcFile is destroyed, that new value is not deleted by the normal ...

Open Graph Description: Bug Description setNominalValue() stores the new pointer in the property through set_attribute_value() 1 2, but the new value is not clearly owned by IfcFile. Later, when IfcFile is destroyed, that...

X Description: Bug Description setNominalValue() stores the new pointer in the property through set_attribute_value() 1 2, but the new value is not clearly owned by IfcFile. Later, when IfcFile is destroyed, that...

Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/8070

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Leaked memory in `IfcPropertySingleValue.NominalValue` with a newly allocated `IfcValue`","articleBody":"### Bug Description\n\n`setNominalValue()` stores the new pointer in the property through `set_attribute_value()` [1](#ref1) [2](#ref2), but the new value is not clearly owned by `IfcFile`. Later, when `IfcFile` is destroyed, that new value is not deleted by the normal file cleanup path [5](#ref5).\n\nAs I understand it, this affects non-entity IFC values such as `IfcLabel`, `IfcReal`, `IfcBoolean`, `IfcInteger`, etc.\n\nExample:\n\n```cpp\n#include \u003cifcparse/IfcFile.h>\n#include \u003cifcparse/Ifc4.h>\n\n#include \u003cstdexcept>\n\nint main()\n{\n    IfcParse::IfcFile file(\"/path/to/any/ifc-file/that/has/any/property/in/the/file.ifc\");\n\n    Ifc4::IfcPropertySingleValue::list::ptr properties =\n        file.instances_by_type\u003cIfc4::IfcPropertySingleValue>();\n\n    Ifc4::IfcPropertySingleValue* prop = nullptr;\n    Ifc4::IfcValue* oldValue = nullptr;\n    // Find any existing property.\n    for (Ifc4::IfcPropertySingleValue::list::it it = properties->begin();\n         it != properties->end();\n         ++it)\n    {\n        oldValue = (*it)->NominalValue(); // (A) existing value loaded from file\n        if (oldValue != nullptr)\n        {\n            prop = *it;\n            break;\n        }\n    }\n\n    if (prop == nullptr)\n        throw std::runtime_error(\"No IfcPropertySingleValue with NominalValue found\");\n\n    prop->setNominalValue(new Ifc4::IfcLabel(\"new\")); // (B) replacement value\n\n    return 0;\n}\n```\n\nWhat i expect:\n\n- `IfcLabel(\"new\")` should be owned and deleted by the file\n- or the API should make it clear that the caller still owns `IfcLabel(\"new\")` and must delete it.\n\nActual behavior:\n\n- `IfcLabel(\"new\")` is stored in the property attribute [2](#ref2).\n- It is not added to the file's owned entity map by `setNominalValue()` [1](#ref1) [2](#ref2).\n- It is not deleted by `IfcFile::~IfcFile()` [5](#ref5).\n\n### Detail\n\nAfter `setNominalValue()`, there are two relevant resources:\n\n- (A) the old `NominalValue`, originally loaded from the IFC file\n- (B) the new `NominalValue`, created by caller code with `new Ifc4::IfcLabel(\"new\")`\n\nFor (A), the old value:\n\n- The value came from the IFC file parser.\n- In current IfcOpenShell, simple type instances read from the file are stored as `std::unique_ptr\u003cIfcUtil::IfcBaseClass>` in `read_simple_type_instances`.\n- Those `unique_ptr`s live in the file storage, so the file has an ownership path for file-loaded simple type instances [6](#ref6).\n\n=> So (A) is fine, not leaked\n\nFor (B), the new replacement value:\n\n- The caller allocates it with `new Ifc4::IfcLabel(\"new\")`.\n- It is freshly allocated.\n- It was not read by the file parser.\n- It is not stored in `read_simple_type_instances`.\n- It is not an IFC entity with a STEP id.\n- It is created after the file was loaded.\n\nThen `setNominalValue()` is called:\n\n```cpp\nprop->setNominalValue(new Ifc4::IfcLabel(\"new\"));\n```\n\nThe generated setter only forwards the raw pointer to `set_attribute_value()`:\n\n```cpp\nvoid Ifc4::IfcPropertySingleValue::setNominalValue(::Ifc4::IfcValue* v) {\n    set_attribute_value(2, v->as\u003cIfcUtil::IfcBaseClass>());\n    if constexpr (false) unset_attribute_value(2);\n}\n```\n\n`set_attribute_value()` then stores the raw pointer in the property's attribute storage:\n\n```cpp\nif constexpr (std::is_pointer_v\u003cT>) {\n    if (t) {\n        data_.set_attribute_value(storage, &declaration(), id() ? id() : identity(), i, t);\n    } else {\n        data_.set_attribute_value(storage, &declaration(), id() ? id() : identity(), i, Blank{});\n    }\n}\n```\n\nThis is where the replacement pointer is stored in the attribute slot [2](#ref2).\n\nIt also updates inverse indexes:\n\n- old inverse unregister [2](#ref2)\n- new inverse register [2](#ref2)\n\nBut this is only relationship bookkeeping. It does not make the file own (B).\n\nSpecifically, `set_attribute_value()` does not call `IfcFile::addEntity()` for (B) [2](#ref2) [3](#ref3), and it does not put (B) into `read_simple_type_instances` [6](#ref6).\n\nHowever, there is a non-entity path in `IfcFile::addEntity()` that can put non-entity instances into `tbyid_`:\n\n```cpp\n} else if (new_entity->file_ == nullptr) {\n    new_entity->file_ = this;\n\n    std::visit([new_entity](auto& m) {\n        if constexpr (std::is_same_v\u003cstd::decay_t\u003cdecltype(m)>, impl::in_memory_file_storage>) {\n            m.tbyid_.insert({ new_entity->identity(), new_entity });\n        }\n    }, storage_);\n}\n```\n\nThis path stores non-entity instances in `tbyid_` [3](#ref3) [4](#ref4).\n\nHowever, (B) never goes through `addEntity()` when assigned through `setNominalValue()` [1](#ref1) [2](#ref2).\n\nEven if caller code manually called `file.addEntity(newValue)`, the current destructor still only deletes `byid_` entries:\n\n```cpp\nIfcParse::IfcFile::~IfcFile() {\n    for (const auto& p : byid_) {\n        delete p.second;\n    }\n}\n```\n\nThe destructor only iterates `byid_` [5](#ref5).\n\nSo `tbyid_` is not an obvious safe ownership/deletion path either.\n\n**With all of above**, that means (B) is left in this state:\n\n- the property attribute points to it\n- inverse indexes may know about the relationship\n- the file does not clearly own it\n- `IfcFile::~IfcFile()` does not clearly delete it\n\n=> (B) appears to leak.\n\nI havent check the python API yet. but it likely we have the same problem.\n\n### References\n\n1. \u003ca id=\"ref1\">\u003c/a>Generated `IfcPropertySingleValue::setNominalValue()` only forwards to `set_attribute_value()`: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/Ifc4.cpp#L12258\n2. \u003ca id=\"ref2\">\u003c/a>`IfcUtil::IfcBaseClass::set_attribute_value()` unregisters old inverse references, stores the new pointer, and registers new inverse references: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L1129\n3. \u003ca id=\"ref3\">\u003c/a>`IfcFile::addEntity()` non-entity path sets `file_` and inserts into `tbyid_`: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L2118\n4. \u003ca id=\"ref4\">\u003c/a>`in_memory_file_storage` contains `byid_` and `tbyid_` maps: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/storage.h#L257.\n5. \u003ca id=\"ref5\">\u003c/a>`IfcFile::~IfcFile()` deletes entries from `byid_` only: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcFile.cpp#L574\n6. \u003ca id=\"ref6\">\u003c/a>File-loaded simple type instances are stored as `read_simple_type_instances` unique pointers and moved into file storage after parsing:\n    - https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/storage.h#L191\n    - https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L566\n    - https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L1608\n\n\n### Attachments\n\n_No response_\n\n### Debug and Error Output\n\n```true\n\n```","author":{"url":"https://github.com/philong6297","@type":"Person","name":"philong6297"},"datePublished":"2026-05-17T08:38:25Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/8070"}

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:33405141-7dc3-9582-20b9-3aaf8b71835e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAE6A:26A2E8:6D8547:92F4E0:6B04AA72
html-safe-nonced69fa67589c40ad150b3f91a052f329638a85833ca61f566eb8a78cf145b2693
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTZBOjI2QTJFODo2RDg1NDc6OTJGNEUwOjZCMDRBQTcyIiwidmlzaXRvcl9pZCI6Ijg4NDI5MTAzNjY1NTMxMjM0NDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2356986d1f582379063bd763540672e13dc39a2e973283243993c58dc8d1b30f
hovercard-subject-tagissue:4462875583
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/IfcOpenShell/IfcOpenShell/8070/issue_layout
twitter:imagehttps://opengraph.githubassets.com/02069df7fda060123a0f8357b88827b8f98aceb2cabb46204fecbe94f9a90651/IfcOpenShell/IfcOpenShell/issues/8070
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/02069df7fda060123a0f8357b88827b8f98aceb2cabb46204fecbe94f9a90651/IfcOpenShell/IfcOpenShell/issues/8070
og:image:altBug Description setNominalValue() stores the new pointer in the property through set_attribute_value() 1 2, but the new value is not clearly owned by IfcFile. Later, when IfcFile is destroyed, that...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamephilong6297
hostnamegithub.com
expected-hostnamegithub.com
None188497a0f45a7aa8f7c866faa1950d1a7f8d82b59416adf549b222ad1d1dd19b
turbo-cache-controlno-preview
go-importgithub.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git
octolytics-dimension-user_id13692563
octolytics-dimension-user_loginIfcOpenShell
octolytics-dimension-repository_id40473201
octolytics-dimension-repository_nwoIfcOpenShell/IfcOpenShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id40473201
octolytics-dimension-repository_network_root_nwoIfcOpenShell/IfcOpenShell
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
release557cfbac6cdb532730c95c90f2cefdc0c4128029
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/IfcOpenShell/IfcOpenShell/issues/8070#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2F8070
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%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2F8070
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=IfcOpenShell%2FIfcOpenShell
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/8070
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/8070
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/8070
IfcOpenShellhttps://github.com/IfcOpenShell
IfcOpenShellhttps://github.com/IfcOpenShell/IfcOpenShell
Codehttps://github.com/IfcOpenShell/IfcOpenShell
Issues1.2k (1.2k)https://github.com/IfcOpenShell/IfcOpenShell/issues
Pull requests937 (937)https://github.com/IfcOpenShell/IfcOpenShell/pulls
Discussionshttps://github.com/IfcOpenShell/IfcOpenShell/discussions
Actionshttps://github.com/IfcOpenShell/IfcOpenShell/actions
Projectshttps://github.com/IfcOpenShell/IfcOpenShell/projects
Wikihttps://github.com/IfcOpenShell/IfcOpenShell/wiki
Security and qualityhttps://github.com/IfcOpenShell/IfcOpenShell/security
Insightshttps://github.com/IfcOpenShell/IfcOpenShell/insights
https://github.com/IfcOpenShell/IfcOpenShell
New issuehttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/8070
New issuehttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/8070
Bughttps://github.com/IfcOpenShell/IfcOpenShell/issues?q=type:"Bug"
Leaked memory in IfcPropertySingleValue.NominalValue with a newly allocated IfcValuehttps://github.com/IfcOpenShell/IfcOpenShell/issues/8070#top
https://github.com/philong6297
philong6297https://github.com/philong6297
on May 17, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#issue-4462875583
1https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref1
2https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref2
5https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref5
2https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref2
1https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref1
2https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref2
5https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref5
6https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref6
2https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref2
2https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref2
2https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref2
2https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref2
3https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref3
6https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref6
3https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref3
4https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref4
1https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref1
2https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref2
5https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#ref5
https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/Ifc4.cpp#L12258https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/Ifc4.cpp#L12258
https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L1129https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L1129
https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L2118https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L2118
https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/storage.h#L257https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/storage.h#L257
https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcFile.cpp#L574https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcFile.cpp#L574
https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/storage.h#L191https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/storage.h#L191
https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L566https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L566
https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L1608https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/ifcparse/IfcParse.cpp#L1608
philong6297https://github.com/philong6297
Bughttps://github.com/IfcOpenShell/IfcOpenShell/issues?q=type:"Bug"
on May 17, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#event-25622940735
petruconduraruhttps://github.com/petruconduraru
PR Proposedhttps://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22PR%20Proposed%22
on Jul 17, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#event-28136973748
petruconduraruhttps://github.com/petruconduraru
PR Proposedhttps://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22PR%20Proposed%22
on Oct 7, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/8070#event-32710361760
Sign up for freehttps://github.com/signup?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/8070
Sign in to commenthttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/8070
Bughttps://github.com/IfcOpenShell/IfcOpenShell/issues?q=type:"Bug"
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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.