calling malloc in fork child is undefined-behaviour
The fork child in https://github.com/GNOME/glib/blob/mainline/glib/gspawn.c#L2216 calls malloc. However, this is undefined behaviour. Only async-signal-safe functions can be called.
The memory should be allocated before fork, or on stack.