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

ATerms are being leaked due to construction and destruction threads not matching, .e.g., in lpsxsim. #1731

Open
mlaveaux opened this issue Dec 11, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mlaveaux
Copy link
Member

Currently term destructions are silently ignored when they do not occur in the protection set.

template <class Key, typename Hash, typename Equals, typename Allocator>
inline typename hashtable<Key,Hash,Equals,Allocator>::iterator hashtable<Key,Hash,Equals,Allocator>::erase(const Key& key)
{
const std::size_t key_index = get_index(key);
auto it = begin() + key_index;
// Find the key.
while (!m_equals(*it, key))
{
++it;
if (it == end())
{
it = begin();
}
if (it == begin() + key_index)
{
// An element not in the hashset is begin removed.
// When optimizing, the gcc compiler tends to generate
// destructions of non generated aterms. If this is
// repaired, this safety escape can be removed.
return it;
}
assert(it != begin() + key_index);
}
*it = nullptr;
--m_number_of_elements;
return it;
}

Disabling this 'safety' escape reveals subtle bugs in how tools interact with the protection sets. One example being that lpxsim creates the Simulation' in the main thread, and then tries to read in an other LPS in a Qt event call ran on a separate thread. This IO operation will delete the original m_stochastic_spec', which was created during initialisation. This results in that ATerm being leaked as it will never be removed from it's original protection set.

@mlaveaux mlaveaux added the bug Something isn't working label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant