-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
int128 as underlying enum type leaks memory #78160
Comments
@llvm/issue-subscribers-clang-frontend Author: Timm Baeder (tbaederr)
Code:
enum A : __int128 {
a,
b
}; Leak reported by asan:
|
I can not reproduce: https://godbolt.org/z/o9P3xMEsW Please provide more details. |
EnumConstantDecl is allocated in the ASTContext's allocator. Destructors are never called for objects allocated in the ASTContext allocator. If the APInt in EnumConstantDecl is larger than 64 bits, the APInt constructor will allocate memory on the heap. This memory never gets destroyed. Perhaps the APIntStorage class that is used to for a similar issue in IntegerLiteral can be extracted and used for EnumContantDecl as well? |
The leak is in the compiler, not the program. asan won't find it unless you build the compiler itself with asan. |
EnumConstantDecl is allocated by the ASTContext allocator so the destructor is never called. This patch takes a similar approach to IntegerLiteral by using APIntStorage to allocate large APSInts using the ASTContext allocator as well. The downside is that an additional heap allocation and copy of the data needs to be made when calling getInitValue if the APSInt is large. Fixes llvm#78160.
EnumConstantDecl is allocated by the ASTContext allocator so the destructor is never called. This patch takes a similar approach to IntegerLiteral by using APIntStorage to allocate large APSInts using the ASTContext allocator as well. The downside is that an additional heap allocation and copy of the data needs to be made when calling getInitValue if the APSInt is large. Fixes #78160.
…cl. (#78311)" With lldb build fix. Original message: EnumConstantDecl is allocated by the ASTContext allocator so the destructor is never called. This patch takes a similar approach to IntegerLiteral by using APIntStorage to allocate large APSInts using the ASTContext allocator as well. The downside is that an additional heap allocation and copy of the data needs to be made when calling getInitValue if the APSInt is large. Fixes #78160.
…78311) EnumConstantDecl is allocated by the ASTContext allocator so the destructor is never called. This patch takes a similar approach to IntegerLiteral by using APIntStorage to allocate large APSInts using the ASTContext allocator as well. The downside is that an additional heap allocation and copy of the data needs to be made when calling getInitValue if the APSInt is large. Fixes llvm#78160.
…cl. (llvm#78311)" With lldb build fix. Original message: EnumConstantDecl is allocated by the ASTContext allocator so the destructor is never called. This patch takes a similar approach to IntegerLiteral by using APIntStorage to allocate large APSInts using the ASTContext allocator as well. The downside is that an additional heap allocation and copy of the data needs to be made when calling getInitValue if the APSInt is large. Fixes llvm#78160.
Code:
enum A : __int128 { a, b };
Leak reported by asan:
The text was updated successfully, but these errors were encountered: