View Issue Details

IDProjectCategoryView StatusLast Update
0002263NoesisGUIC++ SDKpublic2022-02-14 19:56
Reporternikobarli Assigned Tohcpizzi  
PrioritynormalSeveritycrashReproducibilityrandom
Status resolvedResolutionfixed 
Product Version3.1.2 
Target Version3.1.3Fixed in Version3.1.3 
Summary0002263: Crash when running Debug build (HashMap entry is not correctly updated inside AddLoadedXaml)
DescriptionWe experienced crashes when running Debug build of Noesis.

The callstack is as follows:

CallStack[27280]: 7FF9A9538EB6h : Noesis.dll (7FF9A8E80000h) : Noesis::BaseVector<Noesis::BaseComponent *>::Erase + 96h : Vector.inl (561) + 30h
CallStack[27280]: 7FF9A952E269h : Noesis.dll (7FF9A8E80000h) : OnDependencyObjectDestroyed + E9h : UI.cpp (763) + 0h
CallStack[27280]: 7FF9A953AC6Ch : Noesis.dll (7FF9A8E80000h) : Noesis::Delegate<void __cdecl(Noesis::DependencyObject *)>::FreeFuncStub<void (__cdecl*)(Noesis::DependencyObject *)>::Invoke + 3Ch : Delegate.inl (397) + 0h
CallStack[27280]: 7FF9A8F5D973h : Noesis.dll (7FF9A8E80000h) : Noesis::Delegate<void __cdecl(Noesis::DependencyObject *)>::operator() + 53h : Delegate.inl (173) + 0h
CallStack[27280]: 7FF9A8F85DAAh : Noesis.dll (7FF9A8E80000h) : Noesis::Delegate<void __cdecl(Noesis::DependencyObject *)>::MultiDelegate::Invoke + CAh : Delegate.inl (573) + 0h
CallStack[27280]: 7FF9A8F5D973h : Noesis.dll (7FF9A8E80000h) : Noesis::Delegate<void __cdecl(Noesis::DependencyObject *)>::operator() + 53h : Delegate.inl (173) + 0h
CallStack[27280]: 7FF9A8F519DCh : Noesis.dll (7FF9A8E80000h) : Noesis::DependencyObject::OnDestroy + 4Ch : DependencyObject.cpp (557) + 0h
CallStack[27280]: 7FF9A91BC7DEh : Noesis.dll (7FF9A8E80000h) : Noesis::FrameworkElement::OnDestroy + EEh : FrameworkElement.cpp (1632) + 0h
CallStack[27280]: 7FF9A8F22941h : Noesis.dll (7FF9A8E80000h) : Noesis::BaseRefCounted::Release + 91h : BaseRefCounted.inl (41) + 10h
CallStack[27280]: 7FF9A8F7804Bh : Noesis.dll (7FF9A8E80000h) : Noesis::FrameworkElement::Release + 3Bh : FrameworkElement.h (542) + 11h

Debugging the issue, we found the root problem is inside AddLoadedXaml. The problematic sequence is as follows:

- "objects" reference is initialized as gLoadedXamls[uri.Str()];

- "OnDependencyObjectDestroyed(object);" is called
-> internally it may erase entry inside gLoadedXamls, and the internal implementation of gLoadedXamls (HashMap) may reorganize its physical storage

- "objects.PushBack(component);" is called
-> if gLoadedXamls is reorganized in the previous step, the "objects" reference we retrieved before is no longer valid, thus storing the component into it is not correctly updated gLoadedXamls.


static void AddLoadedXaml(BaseComponent* component, const Uri& uri)
{
    DependencyObject* object = DynamicCast<DependencyObject*>(component);
    ResourceDictionary* dictionary = DynamicCast<ResourceDictionary*>(component);

    if (object || dictionary)
    {
        Vector<BaseComponent*>& objects = gLoadedXamls[uri.Str()];
        if (objects.Find(component) == objects.End())
        {
            if (object != nullptr)
            {
                OnDependencyObjectDestroyed(object);
                object->Destroyed() += &OnDependencyObjectDestroyed;
                objects.PushBack(component);
                gComponentXamls[component] = uri.Str();
            }
            else if (dictionary != nullptr)
            {
                OnResourceDictionaryDestroyed(dictionary);
                dictionary->Destroyed() += &OnResourceDictionaryDestroyed;
                objects.PushBack(component);
                gComponentXamls[component] = uri.Str();
            }
        }
    }
}
TagsNo tags attached.
PlatformWindows

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2022-02-08 03:43 nikobarli New Issue
2022-02-08 11:34 sfernandez Assigned To => hcpizzi
2022-02-08 11:34 sfernandez Status new => assigned
2022-02-08 11:34 sfernandez Target Version => 3.1.3
2022-02-14 19:56 sfernandez Status assigned => resolved
2022-02-14 19:56 sfernandez Resolution open => fixed
2022-02-14 19:56 sfernandez Fixed in Version => 3.1.3