After mesh evaluation the shape keys are no longer necessary. Because of this, the key pointer was not copied. As drivers work on evaluated data, however, they do need this key pointer.
I put the new code in mesh_build_data(), as to me that looks like the appropriate spot. However, maybe mesh_build_extra_data() is more suitable? It's unclear to me what's the exact difference between the two.
I also tested with curves and lattices, and they don't show the problem described in T65148: Can't use shape key properties in driver when modifiers generate a new mesh.