Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

foxtran
Copy link

@foxtran foxtran commented Feb 27, 2025

This PR adds automatic deallocation of strings at the end of scopes to avoid possible memory leaks.

!> JUnit output
type(junit_output), intent(inout) :: self

if (allocated(self%xml_start)) deallocate(self%xml_start)
Copy link
Member

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.

Copy link
Author

@foxtran foxtran Feb 27, 2025

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.

Copy link
Member

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.

Copy link
Member

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

Copy link
Member

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants