-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leak fix #48
base: master
Are you sure you want to change the base?
Leak fix #48
Conversation
Tested with ~master dpp |
@@ -69,7 +69,16 @@ alias CXIndex = void*; | |||
/** | |||
* \brief A single translation unit, which resides in an index. | |||
*/ | |||
struct CXTranslationUnitImpl; | |||
struct CXTranslationUnitImpl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang from 14 to at least 19 uses same struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the definition of it though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To hide store pointer to the TranslationUnit
inside of one of the unused fields (CommentToXML
), so that this pointer is accessible to any cursor created from CXTranslationUnit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other ways involve massive Cursor interface changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would change the interface of a type that's from libclang??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that?
As I remember, Cursor
becomes mutable and it is leads to changes in almost all functions what use Cursor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be counter productive to mark code with opaque memory leaks as safe.
Regarding the supported version, that can be easily resolved by bumping the major version. There's no point in supporting old libclang libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be counter productive to mark code with opaque memory leaks as safe.
This is a reason for another PR, there is no need to clutter this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that it's better to rely on the definition to fix the memory leaks instead of trying to keep the library compatible with older versions of libclang.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of trying to keep the library compatible with older versions of libclang.
I don't have such a goal - I'm only worried about the interface changes that affect dpp
(it heavy uses libclang
)
@@ -69,7 +69,16 @@ alias CXIndex = void*; | |||
/** | |||
* \brief A single translation unit, which resides in an index. | |||
*/ | |||
struct CXTranslationUnitImpl; | |||
struct CXTranslationUnitImpl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the definition of it though?
I think this is the reason of crashes:
clang_disposeIndex() - Destroy the given index.
The index must not be destroyed until all of the translation units created within that index have been destroyed.