[gccsdk] fork/exec problems

John Tytgat John.Tytgat at aaug.net
Mon May 7 11:18:41 PDT 2012


In message <f8700c8c52.beeb at ron1954.woosh.co.nz>
          Ron <beeb at woosh.co.nz> wrote:

> In message <77ebe08b52.beeb at ron1954.woosh.co.nz>
>           Ron <beeb at woosh.co.nz> wrote:
> 
> > I appreciate Duncan's  bug report on fork/exec as I am having problems.
> > The latest release 4.1.2 (upgraded last night) reliably halts with
> > segmentation error.
> > Actually previous releases have been giving more erratic faults only 
> > sometimes crashing at the some spot further into the program after
> > returning from the fork.
> > 
> > In the case of Tar, simply replacing fork with vfork or setting
> > Tar$heap "" doesn't work, though I think in the long term, I'll have
> > to change the code so it will work with vfork.
> > The fork/exec is only doing a bit of file renaming for multipart tars,
> > so shouldn't need a full copy of the parent.
> >
>  
> I have vfork() working with the execv command now and straight away
> it looks like any problem is gone.
> 
> I was changing fork() to vfork() in a place that affected all fork()'s
> in the program and that did not work.
> It looks like the fork()/execv combination was the main problem. 
> 
> I notice now I'm using vfork()/execv that the application task size
> does not grow, and it stays at the allocated wimpslot size.
> With fork()/execv, about 740K was added to the displayed task size
> each time that routine was called. The older 4.1.2 would allow this
> to happen sometimes but typically would cause a crash somewhere 
> after a few fork()/execv's.

What do you mean with "older 4.1.2" and "lastest release 4.1.2" ?
"http://www.riscos.info/downloads/gccsdk/gcc-4.1.2-release-1/" vs
"http://www.riscos.info/downloads/gccsdk/testing/4.1.2/" ?

You have to be aware of fork() vs vfork() differences.  One of those
is that the child create with vfork() is sharing the same parent's
address space, while fork() makes a complete copy.  That explains your
observation of wimpslot size changes with fork() and also why this
can only happen in Wimp context.

If you think you found a bug or any unwanted behavior, feel free to
create a bugzilly bug record but do include an as small as possible
test case.  The ones Duncan makes are really superb ones.

John.
-- 
John Tytgat, in his comfy chair at home                                 BASS
John.Tytgat at aaug.net                             ARM powered, RISC OS driven




More information about the gcc mailing list