native: Fix a possible deadlock in spawn
native: Fix a possible deadlock in spawn

The OSX bots have been deadlocking recently in the rustdoc tests. I have only
been able to rarely reproduce the deadlock on my local setup. When reproduced,
it looks like the child process is spinning on the malloc mutex, which I
presume is locked with no other threads to unlock it.

I'm not convinced that this is what's happening, because OSX should protect
against this with pthread_atfork by default. Regardless, running as little code
as possible in the child after fork() is normally a good idea anyway, so this
commit moves all allocation to the parent process to run before the child
executes.

After running 6k iterations of rustdoc tests, this deadlocked twice before, and
after 20k iterations afterwards, it never deadlocked. I draw the conclusion that
this is either sweeping the bug under the rug, or it did indeed fix the
underlying problem.

jashank/rust,defuz/rust,dinfuehr/rust,mdinger/rust,pshc/rust,aidancully/rust,jashank/rust,XMPPwocky/rust,defuz/rust,aneeshusa/rust,jbclements/rust,P1start/rust,pythonesque/rust,ebfull/rust,mihneadb/rust,l0kod/rust,pczarn/rust,robertg/rust,vhbit/rust,carols10cents/rust,P1start/rust,KokaKiwi/rust,rohitjoshi/rust,andars/rust,XMPPwocky/rust,vhbit/rust,vhbit/rust,aturon/rust,philyoon/rust,quornian/rust,quornian/rust,carols10cents/rust,XMPPwocky/rust,reem/rust,TheNeikos/rust,mihneadb/rust,pczarn/rust,0x73/rust,nham/rust,jashank/rust,aneeshusa/rust,untitaker/rust,zubron/rust,avdi/rust,dwillmer/rust,ebfull/rust,defuz/rust,richo/rust,zaeleus/rust,avdi/rust,stepancheg/rust-ide-rust,kwantam/rust,l0kod/rust,philyoon/rust,ejjeong/rust,pelmers/rust,ebfull/rust,michaelballantyne/rust-gpu,reem/rust,jbclements/rust,stepancheg/rust-ide-rust,shepmaster/rand,GBGamer/rust,emk/rust,l0kod/rust,rohitjoshi/rust,ebfull/rust,aepsil0n/rust,AerialX/rust,emk/rust,aepsil0n/rust,seanrivera/rust,pythonesque/rust,AerialX/rust,GBGamer/rust,GrahamDennis/rand,graydon/rust,untitaker/rust,GBGamer/rust,stepancheg/rust-ide-rust,barosl/rust,nwin/rust,mvdnes/rust,jroesch/rust,mihneadb/rust,P1start/rust,gifnksm/rust,zachwick/rust,aturon/rust,quornian/rust,vhbit/rust,krzysz00/rust,sae-bom/rust,nwin/rust,dwillmer/rust,AerialX/rust-rt-minimal,pythonesque/rust,avdi/rust,nham/rust,mdinger/rust,hauleth/rust,ebfull/rust,richo/rust,P1start/rust,aidancully/rust,jbclements/rust,kimroen/rust,pythonesque/rust,zubron/rust,stepancheg/rust-ide-rust,barosl/rust,ktossell/rust,seanrivera/rust,ruud-v-a/rust,dwillmer/rust,kimroen/rust,pelmers/rust,aepsil0n/rust,rprichard/rust,rohitjoshi/rust,jbclements/rust,aidancully/rust,KokaKiwi/rust,quornian/rust,zachwick/rust,kwantam/rust,jbclements/rust,graydon/rust,aturon/rust,victorvde/rust,ruud-v-a/rust,KokaKiwi/rust,rprichard/rust,dinfuehr/rust,emk/rust,dwillmer/rust,nham/rust,ebfull/rand,rohitjoshi/rust,gifnksm/rust,krzysz00/rust,rprichard/rust,erickt/rust,seanrivera/rust,graydon/rust,mvdnes/rust,0x73/rust,zubron/rust,cllns/rust,jroesch/rust,0x73/rust,seanrivera/rust,carols10cents/rust,kwantam/rust,TheNeikos/rust,omasanori/rust,jashank/rust,reem/rust,aepsil0n/rust,jroesch/rust,rprichard/rust,richo/rust,jashank/rust,emk/rust,robertg/rust,nwin/rust,mahkoh/rust,dwillmer/rust,sae-bom/rust,zaeleus/rust,sae-bom/rust,ruud-v-a/rust,victorvde/rust,kimroen/rust,erickt/rust,mahkoh/rust,P1start/rust,mvdnes/rust,barosl/rust,sae-bom/rust,sae-bom/rust,barosl/rust,carols10cents/rust,defuz/rust,zaeleus/rust,rprichard/rust,hauleth/rust,michaelballantyne/rust-gpu,zachwick/rust,AerialX/rust-rt-minimal,pelmers/rust,kimroen/rust,avdi/rust,AerialX/rust,pythonesque/rust,krzysz00/rust,GBGamer/rust,omasanori/rust,cllns/rust,untitaker/rust,KokaKiwi/rust,victorvde/rust,kimroen/rust,aturon/rust,michaelballantyne/rust-gpu,reem/rust,ruud-v-a/rust,aneeshusa/rust,aturon/rust,untitaker/rust,bhickey/rand,zachwick/rust,bombless/rust,KokaKiwi/rust,jbclements/rust,jbclements/rust,dinfuehr/rust,zachwick/rust,bombless/rust,jroesch/rust,bombless/rust-docs-chinese,l0kod/rust,0x73/rust,pshc/rust,mahkoh/rust,krzysz00/rust,pshc/rust,philyoon/rust,carols10cents/rust,Ryman/rust,barosl/rust,vhbit/rust,bluss/rand,mdinger/rust,robertg/rust,omasanori/rust,aepsil0n/rust,ejjeong/rust,l0kod/rust,victorvde/rust,mvdnes/rust,cllns/rust,ktossell/rust,AerialX/rust-rt-minimal,mdinger/rust,0x73/rust,seanrivera/rust,TheNeikos/rust,avdi/rust,graydon/rust,pythonesque/rust,aturon/rust,aturon/rust,vhbit/rust,jashank/rust,mdinger/rust,pczarn/rust,andars/rust,victorvde/rust,defuz/rust,aidancully/rust,reem/rust,robertg/rust,pshc/rust,philyoon/rust,richo/rust,andars/rust,zubron/rust,miniupnp/rust,untitaker/rust,ktossell/rust,hauleth/rust,michaelballantyne/rust-gpu,servo/rust,kwantam/rust,omasanori/rust,P1start/rust,rohitjoshi/rust,emk/rust,bombless/rust,reem/rust,richo/rust,dinfuehr/rust,ejjeong/rust,pshc/rust,zachwick/rust,untitaker/rust,miniupnp/rust,pczarn/rust,AerialX/rust,achanda/rand,kwantam/rust,aneeshusa/rust,bombless/rust,gifnksm/rust,servo/rust,erickt/rust,graydon/rust,XMPPwocky/rust,Ryman/rust,nham/rust,erickt/rust,mvdnes/rust,hauleth/rust,P1start/rust,rohitjoshi/rust,pythonesque/rust,hauleth/rust,0x73/rust,pczarn/rust,avdi/rust,gifnksm/rust,aidancully/rust,GBGamer/rust,jashank/rust,mahkoh/rust,ejjeong/rust,bombless/rust,omasanori/rust,ebfull/rust,servo/rust,mvdnes/rust,XMPPwocky/rust,pelmers/rust,rprichard/rust,robertg/rust,pshc/rust,AerialX/rust-rt-minimal,miniupnp/rust,nwin/rust,servo/rust,AerialX/rust,ejjeong/rust,huonw/rand,nham/rust,cllns/rust,ktossell/rust,mihneadb/rust,jroesch/rust,robertg/rust,mahkoh/rust,sae-bom/rust,jroesch/rust,GBGamer/rust,nham/rust,krzysz00/rust,mihneadb/rust,erickt/rust,philyoon/rust,cllns/rust,ktossell/rust,servo/rust,mdinger/rust,krzysz00/rust,quornian/rust,AerialX/rust-rt-minimal,arthurprs/rand,richo/rust,carols10cents/rust,waynenilsen/rand,pshc/rust,michaelballantyne/rust-gpu,dwillmer/rust,andars/rust,quornian/rust,gifnksm/rust,aepsil0n/rust,AerialX/rust,miniupnp/rust,TheNeikos/rust,TheNeikos/rust,vhbit/rust,ruud-v-a/rust,zubron/rust,stepancheg/rust-ide-rust,victorvde/rust,pczarn/rust,barosl/rust,gifnksm/rust,emk/rust,erickt/rust,dinfuehr/rust,miniupnp/rust,nwin/rust,mahkoh/rust,miniupnp/rust,zaeleus/rust,retep998/rand,nham/rust,l0kod/rust,kimroen/rust,servo/rust,nwin/rust,quornian/rust,ktossell/rust,0x73/rust,AerialX/rust-rt-minimal,seanrivera/rust,miniupnp/rust,stepancheg/rust-ide-rust,XMPPwocky/rust,andars/rust,jbclements/rust,erickt/rust,dwillmer/rust,pelmers/rust,ejjeong/rust,Ryman/rust,zubron/rust,michaelballantyne/rust-gpu,hauleth/rust,pelmers/rust,ruud-v-a/rust,l0kod/rust,jbclements/rust,kwantam/rust,philyoon/rust,bombless/rust,miniupnp/rust,aneeshusa/rust,Ryman/rust,ktossell/rust,zaeleus/rust,Ryman/rust,vhbit/rust,pczarn/rust,andars/rust,omasanori/rust,l0kod/rust,pshc/rust,GBGamer/rust,zubron/rust,nwin/rust,GBGamer/rust,zubron/rust,barosl/rust,aidancully/rust,emk/rust,jroesch/rust,michaelballantyne/rust-gpu,nwin/rust,aneeshusa/rust,zaeleus/rust,kimroen/rust,cllns/rust,mihneadb/rust,servo/rust,defuz/rust,Ryman/rust,Ryman/rust,KokaKiwi/rust,graydon/rust,dinfuehr/rust,stepancheg/rust-ide-rust,dwillmer/rust,jroesch/rust,jashank/rust,TheNeikos/rust