diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-08-31 10:41:03 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-08-31 10:41:03 -0700 |
| commit | 60ed10520dd9af285e7d865445427caedc7e1ec6 (patch) | |
| tree | b7c3c0003d6d8d67f3f04f136af083deaa5e591b /source/core | |
| parent | 227f9f5a9d8ac0d88079b6175b3f31c8f05fabd0 (diff) | |
Fix some issues around cloned modifiers.
The root of the problem here is that:
- We do a shallow copy of modifiers when "lowering" declarations/statements, by just copying over the head pointer of the linked list of modifiers
- During lowering we sometimes add additional modifiers (only used during lowering), and these can thus accidentally get added to the end of the list of modifiers for the original declaration (rather than just the lowered decl)
- If the same declaration is used by multiple entry points to be output, then a modifier added by the first entry point (which could reference entry-point-specific storage) will be earlier in the modifier list and might be picked up by a later entry point, so that we dereference already released memory
The simple fix for right now is the use the support for a "shared" modifier node to ensure that each lowered declaration/statement gets a unique modifier list.
A better long-term fix is:
1. Don't use modifiers to store general side-band information, and instead use proper lookup tables that own their contents.
2. Don't use a linked list to store modifiers (this was done to make splicing easy, but now we have a whole class of bugs related to bad splices), and be willing to clone them as needed.
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/smart-pointer.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/source/core/smart-pointer.h b/source/core/smart-pointer.h index 87cb40d70..3e64eac96 100644 --- a/source/core/smart-pointer.h +++ b/source/core/smart-pointer.h @@ -49,6 +49,11 @@ namespace Slang SLANG_ASSERT(referenceCount != 0); return referenceCount == 1; } + + UInt debugGetReferenceCount() + { + return referenceCount; + } }; inline void addReference(RefObject* obj) |
