After deleting an object, the call free_and_unlink_base() takes care of NULLifying object pointers. But, with exception of constraints. Silly!!! So, in the end of a function additionally the test_scene_constraints() has to be called to prevent crashes. This was missing in join_mesh and convert_object.