Closed MichaelGoulding closed 3 years ago
Thanks for reporting this issue! Could you help me figure out how to reproduce this?
Are you making one component to contain itself as a children?
Here is the repro.
With x64-Debug preset, typing "exit" and pressing enter results in the crash.
Thanks! I will take a look.
but things seems to work.
Maybe this is Windows only. In this case, there are some chances this is fixe by: https://github.com/ArthurSonzogni/FTXUI/commit/18d1b04b7adb1c85515b7663a81d3ca18f255d23
Hey @MichaelGoulding, I landed a few patches. Since I can't reproduce your problem, it is quite hard for me to fix. However I have good hope it might be fixed (~10% probability). Could you please check whether this has been fixed on the latest patch?
With this example:
{
auto cmdInput = Input(&g_currentCmdString, "enter command");
auto layout = Container::Vertical({
cmdInput,
});
}
The layout class is destroyed before the cmdInput class, so the parent pointer points to bogus memory in cmdInput. cmdInput's Detach() method then tries to remove itself from the parent's children list in its destructor, leading to a crash in Window's Debug mode.
MSVC catches this in Debug mode because the memory for layout appears to be set to a known bad value after destruction.
You might be able to reproduce this with AddressSanitizer on Linux.
I think the fix might be to use a weak_ptr for the parent object so that you know if the parent is already destroyed, or you can have the parent component detach all its children on destruction.
Indeed! This is very weird this got unnoticed for so long!
Could you confirm this has been fixed by latest patch?
See my comments for #117
See my comments for #117
Fixed! Thanks!
Do you see any other issues?
not right now. thanks!
Often, when exiting from main, I get this crash: