I see the problem in vim creating the gtk menu before the fork(). With the original gtk menu this is no problem. But appmenu-gtk creates the menu using dbus. Probably, the dbus connection for the global menu creation does not survive the fork(). Or, if the dbus connection survives the fork, it might be that the ongoing dbus transaction (i.e. the menu creation) does not.
I see the problem in vim creating the gtk menu before the fork(). With the original gtk menu this is no problem. But appmenu-gtk creates the menu using dbus. Probably, the dbus connection for the global menu creation does not survive the fork(). Or, if the dbus connection survives the fork, it might be that the ongoing dbus transaction (i.e. the menu creation) does not.