SIGSEGV with URL class

Hello JUCE Community.

While developing my plugin I encountered a really weird issue with the URL class.
I am using a HyperlinkButton, and when I use HyperlinkButton::setURL, it copies the the passed URL object to the button’s.

That’s where the problems arise.
After hours of tracking down the issue, I came across the URL::filesToUpload variable which’s copy constructor seems to trigger a SIGSEGV.
I am using GCC in Release configuration on Linux 64 bit.

Through coincidence, because I put Logger statements everywhere to track the issue down, it happened that it started to work again when I put a Logger statement between two lines,
like this:

    ReferenceCountedArray (const ReferenceCountedArray& other) noexcept
{
    const ScopedLockType lock (other.getLock());
    values.addArray (other.begin(), other.size());
    
    Logger::getCurrentLogger()->writeToLog("ReferenceCountedArray::operator=(copy)");
    
    for (auto* o : *this)
        if (o != nullptr)
            o->incReferenceCount();
}

Since this totally unrelated statement made the thing work again and I am in Release mode, I figured it might be some weird GCC re-ordering issue.
Please correct me if I’m mistaken, I began developing with C++ a year ago.

How would I fix this and, out of interest, why does this happen?

Ok I put a memory barrier in between to stop the problems for now, works like a charm.

Only thing that bothers me is that it required changing JUCE code and that can’t be a permanent solution, so I am hoping still for any tips or maybe it even needs a fix, I don’t know.

Anyway, for now it works.