-
Notifications
You must be signed in to change notification settings - Fork 24
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
Finalize structures #45
base: main
Are you sure you want to change the base?
Conversation
…the end of lifetimes
!> JUnit output | ||
type(junit_output), intent(inout) :: self | ||
|
||
if (allocated(self%xml_start)) deallocate(self%xml_start) |
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.
The xml_start
string is declared as:
character(len=:), allocatable :: xml_start
My understanding is that the compiler will always deallocate, unless there is a bug in a compiler.
Did you find a case when this leaks memory? If so, if you could post it, we can create a minimal reproducible example and submit it as a bug to the compiler vendor.
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.
Did you find a case when this leaks memory? If so, if you could post it, we can create a minimal reproducible example and submit it as a bug to the compiler vendor.
Yep. Try to compile test-suite with AddressSanitizer with GCC-14.
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.
But is it a bug in GCC or in test-drive? And if it is a bug in GCC, should we workaround the bug in test-drive? We probably should, until they fix it. I'll leave it to @awvwgk to decide.
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.
there is a bug with finalization in gcc-14, it is hard to draw a mwe but this issue could be related to that
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.
Unfortunately, gcc has several finalization related bugs. (Funny enough, I also found one when developing a unit testing system 😄). Some of them you can work around, and some of them you can not really. In Fortuno, we managed to work around those,so it runs with the address sanitizer without reporting problems.
I think, a testing system should try to work around those issues, because it is somewhat annoying and when the testing framework generates memory leak errors, as if people get used to that, they will just ignore any kind of those errors, even if it is a real bug in their part of the code (and not just compiler artifacts).
This PR adds automatic deallocation of strings at the end of scopes to avoid possible memory leaks.