Unity Error when calling Button.onClick.Invoke();

I’m having some weird issues when calling the Button.onClick.Invoke() method. According to the Scripting API it is used to invoke all the callbacks that are registered to that button, which is exactly what I’m trying to do.

Sadly when I call this method, Unity hangs for a second and then starts giving me these weird errors:
TLS Allocator ALLOC_TEMP_THREAD, underlying allocator ALLOC_TEMP_THREAD has unfreed allocations

Followed by a couple of these logs, and then repeats.
Allocation of 1280 bytes at 06179290

Another thing to note is that when I stop running and start again these errors appear without calling the method. I have to completely quit Unity and restart it to get rid of these errors.

A quick Google search has not given me any answers. Does someone here know what causes these errors?

Looks like an engine bug!

Are the callbacks registered in the inspector or in code?

Callbacks are registered in code, Button.onClick.AddListener(). I already found the culprit, but I would’ve expected a different error to pop up.

I introduced an Infinite Loop. An incredibly simple example would be as seen below, it wasn’t as obvious in my project though.

Button.onClick.AddListener(Toggle);

public void Toggle()
{
     Button.onClick.Invoke();
}

I just write:
if (MyButton != null)
MyButton.onClick.Invoke();
Then error doesn’t appear