[comp.lang.perl] perl & vfork on sparc machines

lm@slovax.Eng.Sun.COM (Larry McVoy) (04/20/91)

I was porting perl to an alpha copy of our next release of the OS and ran
into the following problem.  It is unlikely that you will see this, but
just in case...

In util.c, function mypopen(), there is a line like so:

	while ((pid = (doexec?vfork():fork())) < 0)

The problem showed up when I compiled w/ the optimizer turned on.  The bug
is that the internal release did not have a copy of vfork.h which has a
pragma that tells the compiler not to optimize around vfork()s (a vfork
is quite similar to a longjmp and both have a nasty interactions with 
register allocations).  The arg "mode" was in a register and it got
stomped on by the child.

The only reason I mention it is that you may run into the problem on
some other risc that doesn't have vfork.h or calls it something else.
Pretty unlikely, but you never know.
---
Larry McVoy, Sun Microsystems     (415) 336-7627       ...!sun!lm or lm@sun.com

meissner@osf.org (Michael Meissner) (04/23/91)

In article <549@appserv.Eng.Sun.COM> lm@slovax.Eng.Sun.COM (Larry McVoy) writes:

| I was porting perl to an alpha copy of our next release of the OS and ran
| into the following problem.  It is unlikely that you will see this, but
| just in case...
| 
| In util.c, function mypopen(), there is a line like so:
| 
| 	while ((pid = (doexec?vfork():fork())) < 0)
| 
| The problem showed up when I compiled w/ the optimizer turned on.  The bug
| is that the internal release did not have a copy of vfork.h which has a
| pragma that tells the compiler not to optimize around vfork()s (a vfork
| is quite similar to a longjmp and both have a nasty interactions with 
| register allocations).  The arg "mode" was in a register and it got
| stomped on by the child.
| 
| The only reason I mention it is that you may run into the problem on
| some other risc that doesn't have vfork.h or calls it something else.
| Pretty unlikely, but you never know.

I may be mistaken, but Sun seems to be the only system with such
problems.  Maybe it's because of register windows.....
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Considering the flames and intolerance, shouldn't USENET be spelled ABUSENET?