Debugging JavaScriptCore heap crashes in Big Sur

I have a JavaScriptCore scripting interface in my app. After migrating to Big Sur, I'm getting constant crashes after the context has already been abandoned and all of the code evaluated.

I have multiple JSContext instances, each with their own virtual machine, one created for all of the scripts separately.

I'm getting both general protection faults (EXC_I386_GPFLT) and more general bad access crashes (ie. Heap Helper Thread (30): EXC_BAD_ACCESS (code=1, address=0x7ffdde3bdf0)

I'm guessing that something somewhere tries to access stuff that is no longer there, even though this shouldn't happen as any execution has already ended. Is there a way to create some sort of protection against this, and how do I effectively debug these errors? Can't really step into evaluated JavaScript :-)

Also, is there a way to effectively null the context and VM after execution to tell them that they are no longer needed?

Debugging JavaScriptCore heap crashes in Big Sur
 
 
Q