I think i've found the problem that causes this crash. MOD_surface.c deformVerts, calls BKE_id_free on surmd->mesh. This frees the cached tree used by surmd->bvhtree. surmd->bvhtree is not rebuilt until later, so other threads can access the invalid bvhtree. setting surmd->bvhtree to NULL stops this happening.
The deeper issue here is a race condition due to missing dependencies. But this code is problematic too, so I'll commit a modified version of this patch as well.
This is not equivalent, it does not use MEM_SAFE_FREE in case memory allocation failed.
Blender comment style uses /* */.
If allocation of surmd->mesh fails, this bvhtree will not be freed.