View Issue Details

IDProjectCategoryView StatusLast Update
0001424NoesisGUIC++ SDKpublic2019-05-14 23:39
ReporterrealesmediaAssigned Tojsantos 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.2.0b10 
Target Version2.2.3Fixed in Version2.2.3 
Summary0001424: crash on closing the window (NoesisApp::Window)
DescriptionWe use a multi-window interface. When you close the window using the Close () method, crash occurs in the destructor

..Src\Packages\App\ApplicationLauncher\Src\window.cpp

Window::~Window()
{
    mClosed(this, EventArgs::Empty);

    if (mDisplay != 0)
    {
        mDisplay->LocationChanged() -= MakeDelegate(this, &Window::OnDisplayLocationChanged); !!!!! Crash
        . . .
    }
}

void Window::Close()
{
    if (mDisplay != 0)
    {
        mDisplay->Close();
       mDisplay = nullptr; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    }
}
TagsC++
PlatformWindows

Activities

jsantos

jsantos

2019-04-02 20:20

manager   ~0005589

Sorry, I am not following here. Could you please elaborate a bit more about where the crash is happening? What display implementation are you using?

I just tried in one of our examples doing a manual close and everything is working fine (Windows 10)
realesmedia

realesmedia

2019-04-08 15:50

reporter  

screen.jpg (1,468,819 bytes)
realesmedia

realesmedia

2019-04-08 15:50

reporter   ~0005616

Hi

I inherit from NoesisApp::Window. I create several dialog windows. if you close the window using the Window::Close() method, then ~Window () will crash.


fix method
NoesisApp::Window::Close()
{
    if (mDisplay != 0)
    {
        mDisplay->Close();
        mDisplay = nullptr; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    }
}
jsantos

jsantos

2019-04-08 16:19

manager   ~0005617

What crash are you getting if you don't set mDisplay to nullptr? Could you please paste the callstack?
realesmedia

realesmedia

2019-04-09 16:32

reporter   ~0005619

if mDisplay is not set to nullptr, the destructor tries to unsubscribe from the events mDisplay

..Src\Packages\App\ApplicationLauncher\Src\window.cpp

Window::~Window()
{
    mClosed(this, EventArgs::Empty);

    if (mDisplay != 0) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    {
        mDisplay->LocationChanged() -= MakeDelegate(this, &Window::OnDisplayLocationChanged); !!!!! Crash
        . . .
    }
}
jsantos

jsantos

2019-04-10 13:51

manager   ~0005623

Yes, but I don't understand why unsubscribing is crashing when using two windows. Could you please paste the callstack when crashing?
realesmedia

realesmedia

2019-04-10 14:41

reporter   ~0005624

Last edited: 2019-04-10 14:46

View 2 revisions

Does not depend on the number of windows. after calling Window :: Close () mDisplay is destroyed. ~ Windows () tries to access it.

System:
Windows 10, DX11, (Win32Display)

realesmedia

realesmedia

2019-04-10 14:56

reporter   ~0005625

Last edited: 2019-04-10 15:06

View 2 revisions

Dump

https://yadi.sk/d/j3ii39MeZAi8cQ

jsantos

jsantos

2019-04-10 14:59

manager   ~0005626

Our Window::Close does not destroy the display
void Window::Close()
{
    if (mDisplay != 0)
    {
        mDisplay->Close();
    }
}


So I am not sure how the crash is happening. I tried reproducing the issue.

I need a callstack with the crash please, not a dump.

Thanks!
realesmedia

realesmedia

2019-04-10 15:15

reporter   ~0005627

ucrtbased.dll!00007ffe87387f65() Unknown Non-user code. Cannot find or open the PDB file.
     ucrtbased.dll!00007ffe87388103() Unknown Non-user code. Cannot find or open the PDB file.
     ucrtbased.dll!00007ffe8739d7dd() Unknown Non-user code. Cannot find or open the PDB file.
     vcruntime140d.dll!00007ffe96629051() Unknown Non-user code. Cannot find or open the PDB file.
     NoesisApp.dll!Noesis::Delegate<void __cdecl(NoesisApp::Display *,int,int)>::Remove(const Noesis::Delegate<void __cdecl(NoesisApp::Display *,int,int)> & d={...}) Line 137 C++ Symbols loaded.
     NoesisApp.dll!Noesis::Delegate<void __cdecl(NoesisApp::Display *,int,int)>::operator-=(const Noesis::Delegate<void __cdecl(NoesisApp::Display *,int,int)> & d={...}) Line 143 C++ Symbols loaded.
> NoesisApp.dll!NoesisApp::Window::~Window() Line 71 C++ Symbols loaded.
     Engine.dll!Miracle::Gui::WindowEx::~WindowEx() Line 334 C++ Symbols loaded.
     Engine.dll!Docking::LayoutWindow::~LayoutWindow() C++ Non-user code. Symbols loaded.
     Engine.dll!Docking::LayoutWindow::`vector deleting destructor'(unsigned int) C++ Non-user code. Symbols loaded.
     Noesis.dll!00007ffe655a1516() Unknown Non-user code. Cannot find or open the PDB file.
     Engine.dll!Docking::LayoutWindow::Release() Line 17 C++ Symbols loaded.
     Engine.dll!Docking::DockManager::CreateLayoutWindow::__l2::<lambda>() Line 199 C++ Symbols loaded.
     Engine.dll!std::_Invoker_functor::_Call<void <lambda>(void) &>(Docking::DockManager::CreateLayoutWindow::__l2::void <lambda>(void) & _Obj=void <lambda>(void){...}) C++ Non-user code. Symbols loaded.
     Engine.dll!std::invoke<void <lambda>(void) &>(Docking::DockManager::CreateLayoutWindow::__l2::void <lambda>(void) & _Obj=void <lambda>(void){...}) C++ Non-user code. Symbols loaded.
     Engine.dll!std::_Invoker_ret<void,1>::_Call<void <lambda>(void) &>(Docking::DockManager::CreateLayoutWindow::__l2::void <lambda>(void) & <_Vals_0>=void <lambda>(void){...}) C++ Non-user code. Symbols loaded.
     Engine.dll!std::_Func_impl_no_alloc<void <lambda>(void),void>::_Do_call() C++ Non-user code. Symbols loaded.
     Engine.dll!std::_Func_class<void>::operator()() C++ Non-user code. Symbols loaded.
     Engine.dll!std::_Invoker_functor::_Call<std::function<void __cdecl(void)> &>(std::function<void __cdecl(void)> & _Obj={...}) C++ Non-user code. Symbols loaded.
     Engine.dll!std::invoke<std::function<void __cdecl(void)> &>(std::function<void __cdecl(void)> & _Obj={...}) C++ Non-user code. Symbols loaded.
     Engine.dll!std::_Invoker_ret<std::_Unforced,0>::_Call<std::function<void __cdecl(void)> &>(std::function<void __cdecl(void)> & <_Vals_0>={...}) C++ Non-user code. Symbols loaded.
     Engine.dll!std::_Call_binder<std::_Unforced,std::function<void __cdecl(void)>,std::tuple<>,std::tuple<> >(std::_Invoker_ret<std::_Unforced,0> __formal={...}, std::integer_sequence<unsigned __int64> __formal={...}, std::function<void __cdecl(void)> & _Obj={...}, std::tuple<> & _Tpl={...}, std::tuple<> && _Ut={...}) Line 1859 C++ Non-user code. Symbols loaded.
     Engine.dll!std::_Binder<std::_Unforced,std::function<void __cdecl(void)> &>::operator()<>() Line 1914 C++ Non-user code. Symbols loaded.
     Engine.dll!std::_Invoker_functor::_Call<std::_Binder<std::_Unforced,std::function<void __cdecl(void)> &> &>(std::_Binder<std::_Unforced,std::function<void __cdecl(void)> &> & _Obj={...}) C++ Non-user code. Symbols loaded.
     Engine.dll!std::invoke<std::_Binder<std::_Unforced,std::function<void __cdecl(void)> &> &>(std::_Binder<std::_Unforced,std::function<void __cdecl(void)> &> & _Obj={...}) C++ Non-user code. Symbols loaded.
     Engine.dll!std::_Invoker_ret<void,1>::_Call<std::_Binder<std::_Unforced,std::function<void __cdecl(void)> &> &>(std::_Binder<std::_Unforced,std::function<void __cdecl(void)> &> & <_Vals_0>={...}) C++ Non-user code. Symbols loaded.
     Engine.dll!std::_Func_impl_no_alloc<std::_Binder<std::_Unforced,std::function<void __cdecl(void)> &>,void>::_Do_call() C++ Non-user code. Symbols loaded.
     Globals.dll!std::_Func_class<void>::operator()() C++ Non-user code. Symbols loaded.
     Globals.dll!Global::Dispatcher::Update(float global_time=7.90762854) Line 13 C++ Symbols loaded.
     Engine.dll!MiracleEngine::Update() Line 267 C++ Symbols loaded.
     Engine.dll!MiracleEngine::Run() Line 344 C++ Symbols loaded.
     Miracle.exe!WinMain(HINSTANCE__ * hInstance=0x00007ff71c9d0000, HINSTANCE__ * hPrevInstance=0x0000000000000000, char * lpCmdLine=0x000001e9c1d05557, int nCmdShow=10) Line 78 C++ Symbols loaded.
     Miracle.exe!invoke_main() Line 107 C++ Non-user code. Symbols loaded.
     Miracle.exe!__scrt_common_main_seh() Line 288 C++ Non-user code. Symbols loaded.
     Miracle.exe!__scrt_common_main() Line 331 C++ Non-user code. Symbols loaded.
     Miracle.exe!WinMainCRTStartup() Line 17 C++ Non-user code. Symbols loaded.
     kernel32.dll!00007ffec33b3dc4() Unknown Non-user code. Cannot find or open the PDB file.
     ntdll.dll!00007ffec5ce3691() Unknown Non-user code. Cannot find or open the PDB file.
realesmedia

realesmedia

2019-04-10 15:23

reporter   ~0005628

Window()::Close() -> Win32Display()-> SendMessage(mWindowHandle, WM_CLOSE, 0, 0); -> ~Win32Display()

~Window() mDsiplay(Win32Display) destroed
realesmedia

realesmedia

2019-04-10 16:29

reporter   ~0005629

excuse this in our inherited class WindowEx :: Close is called Display.Reset (). This is a feature of the implementation of our WindowsEx. Using the WindowEx class is similar to using the WPF Window. I inherited the WindowEx class from NoesisApp :: Window and made members of the Display class and the RenderContext class. This works fine, but when I close the window, I cannot notify Window that Display has been destroyed, As a variant remove unbind mDisplay in the method Window::Shutdown ()

simplified WindowEx:


    class ENGINE_API WindowEx : public NoesisApp::Window
    {
        using Base = NoesisApp::Window;
        using This = WindowEx;

    public:

        WindowEx() {
                         Noesis::GUI::LoadComponent(this, "Global/GUI/Windows/WindowEx.xaml");
                         Initialize();
                 }

        virtual ~WindowEx();

        void Show(bool activate=true);
        void ShowDialog();
        void Hide();

                void Initialize()
                {
               m_display = NoesisApp::CreateDisplay();
               m_render_context = NoesisApp::RenderContext::Create("D3D11");
              m_render_context->Init(m_display->GetNativeHandle(), Global::api.gfx->GetDX11RenderContext(), Noesis::Device::Get(), m_samples, false, true);
            m_render_context->Resize();

             Base::Init(m_display, m_render_context, eastl::max_alt(m_samples, 1U), m_ppaa);
               }

        void Shutdown() {
                         Base::Shutdown();
                  m_display.Reset();
                   m_render_context->Shutdown();
                  m_render_context.Reset();
                }

        void Close() {
              Base::Close();
              Shutdown();
                  }

    protected:
        Noesis::Ptr<NoesisApp::Display> m_display;
        Noesis::Ptr<NoesisApp::RenderContext> m_render_context;

        NS_DECLARE_REFLECTION(This, Base)
    };
jsantos

jsantos

2019-04-10 16:32

manager   ~0005630

So there is nothing wrong at our code right? Can we close this?
realesmedia

realesmedia

2019-04-10 16:46

reporter   ~0005631

Yes. Only if it is possible to transfer the ~ Window() code to Window::Shutdown()

thanks
jsantos

jsantos

2019-04-10 16:57

manager   ~0005632

Yes, that makes sense. Moving the code from the destructor to the end of Shutdown().

Could you try it and let me know if it works for you?
realesmedia

realesmedia

2019-04-10 16:59

reporter   ~0005633

I tested this option. works good)))

Issue History

Date Modified Username Field Change
2019-03-14 10:27 realesmedia New Issue
2019-03-14 10:27 realesmedia Tag Attached: C++
2019-03-14 10:28 realesmedia Severity feature => minor
2019-03-14 10:28 realesmedia Steps to Reproduce Updated View Revisions
2019-03-14 11:08 realesmedia Steps to Reproduce Updated View Revisions
2019-03-14 16:04 realesmedia Steps to Reproduce Updated View Revisions
2019-03-18 22:23 sfernandez Assigned To => jsantos
2019-03-18 22:23 sfernandez Status new => assigned
2019-03-18 22:23 sfernandez Target Version => 2.2.1
2019-04-02 20:20 jsantos Note Added: 0005589
2019-04-02 20:21 jsantos Status assigned => feedback
2019-04-02 20:21 jsantos Target Version 2.2.1 =>
2019-04-08 15:50 realesmedia File Added: screen.jpg
2019-04-08 15:50 realesmedia Note Added: 0005616
2019-04-08 15:50 realesmedia Status feedback => assigned
2019-04-08 16:19 jsantos Status assigned => feedback
2019-04-08 16:19 jsantos Note Added: 0005617
2019-04-09 16:32 realesmedia Note Added: 0005619
2019-04-09 16:32 realesmedia Status feedback => assigned
2019-04-10 13:51 jsantos Note Added: 0005623
2019-04-10 13:51 jsantos Status assigned => feedback
2019-04-10 14:41 realesmedia Note Added: 0005624
2019-04-10 14:41 realesmedia Status feedback => assigned
2019-04-10 14:46 realesmedia Note Edited: 0005624 View Revisions
2019-04-10 14:56 realesmedia Note Added: 0005625
2019-04-10 14:59 jsantos Note Added: 0005626
2019-04-10 14:59 jsantos Status assigned => feedback
2019-04-10 15:06 realesmedia Note Edited: 0005625 View Revisions
2019-04-10 15:15 realesmedia Note Added: 0005627
2019-04-10 15:15 realesmedia Status feedback => assigned
2019-04-10 15:23 realesmedia Note Added: 0005628
2019-04-10 16:29 realesmedia Note Added: 0005629
2019-04-10 16:32 jsantos Note Added: 0005630
2019-04-10 16:33 jsantos Status assigned => feedback
2019-04-10 16:46 realesmedia Note Added: 0005631
2019-04-10 16:46 realesmedia Status feedback => assigned
2019-04-10 16:57 jsantos Note Added: 0005632
2019-04-10 16:57 jsantos Status assigned => feedback
2019-04-10 16:59 realesmedia Note Added: 0005633
2019-04-10 16:59 realesmedia Status feedback => assigned
2019-04-10 17:03 jsantos Target Version => 2.2.2
2019-04-30 10:55 sfernandez Target Version 2.2.2 => 2.2.3
2019-05-14 23:38 jsantos Fixed in Version => 2.2.3
2019-05-14 23:39 jsantos Status assigned => resolved
2019-05-14 23:39 jsantos Resolution open => fixed