Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
Clang CC
l_inc:
--- Quote from: l_inc on November 10, 2015, 03:50:32 pm ---So this seems to be a use after free inside the plugin. This happens pretty much every time when closing a tab with a header file.
--- End quote ---
Just checked it again, cause the bug's too annoying. This is indeed a use after free, cause clang_getDiagnosticSetFromTU(m_ClTranslUnit); in TranslationUnit::GetDiagnostics is called after clang_disposeTranslationUnit(m_ClTranslUnit); in the TranslationUnit::~TranslationUnit() for the same m_ClTranslUnit, i.e. the TranslationUnit object is reused (by ClangProxy::GetDiagnostics) after its destructor was called as a result of ClangProxy::RemoveTranslationUnit .
yvesdm3000:
--- Quote from: l_inc on November 10, 2015, 06:19:30 pm ---
--- Quote from: l_inc on November 10, 2015, 03:50:32 pm ---So this seems to be a use after free inside the plugin. This happens pretty much every time when closing a tab with a header file.
--- End quote ---
Just checked it again, cause the bug's too annoying. This is indeed a use after free, cause clang_getDiagnosticSetFromTU(m_ClTranslUnit); in TranslationUnit::GetDiagnostics is called after clang_disposeTranslationUnit(m_ClTranslUnit); in the TranslationUnit::~TranslationUnit() for the same m_ClTranslUnit, i.e. the TranslationUnit object is reused (by ClangProxy::GetDiagnostics) after its destructor was called as a result of ClangProxy::RemoveTranslationUnit .
--- End quote ---
Thanks for the feedback. I'll include a fix in my next push for this.
Yves
l_inc:
Alpha, yvesdm3000
OK. This was an easy one. Someone just doesn't know, what std::vector::assign is meant for. Btw. I hope those who wrote the copy-constructor of the TranslationUnit as simulating a move-contructor for speed know what they do, cause it might become unsafe.
Patch attached.
yvesdm3000:
--- Quote from: l_inc on November 10, 2015, 08:22:54 pm ---Alpha, yvesdm3000
OK. This was an easy one. Someone just doesn't know, what std::vector::assign is meant for. Btw. I hope those who wrote the copy-constructor of the TranslationUnit as simulating a move-contructor for speed know what they do, cause it might become unsafe.
Patch attached.
--- End quote ---
I noticed the construction too. As long as it doesn't give me trouble I keep it as-is, it does help to keep the lifetime of the clang TU correct without additional pointers. For the file-id list, I did not investigate yet why we need the swap there... I don't want to be too negative, the plugin is still a very good starting point!
Having real C++11 and wxWidgets 2.9 (for some thread goodies) as minimum requirements is whishful thinking I guess...
Yves
yvesdm3000:
For the std::vector::assign, that must have been me, and I don't even understand myself how I could have written that, probably late hours and lack of sleep.
Yves
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version