Hxcpp - Bad local allocator - requesting memory from unregistered thread

I have code that worked before without any crashes but in more recent haxe versions, I get this error:

Bad local allocator - requesting memory from unregistered thread!

Now, even though it worked before I actually do believe this is probably the result of me doing something wrong. I’m using a third party c++ lib that itself spawns new threads and that thread does end up calling haxe code. So what I haven’t been able to find through googling is how do I register a thread with the haxe gc (ideally one doesn’t allocate anything in this thread, but I have no way of guaranteeing that the haxe code avoids that).

Answering my own question - I just needed to call SetTopOfStack to register the thread with gc:

in the callback:

        int base = 0;
        hx::SetTopOfStack(&base, true);

        // call haxe code here
        
        hx::SetTopOfStack((int*)0, true);