[gccsdk] Possible crash with system() call

John Tytgat John.Tytgat at aaug.net
Sat Jul 14 07:43:56 PDT 2012

In message <SNT136-W5279A0B6274CE8B9DF1595F0D60 at phx.gbl>
          alan buckley <alan_baa at hotmail.com> wrote:

> I've been getting a mysterious crash and think I may have tracked
> it down to the use of a system() call. Unfortunatly I can't be sure
> as it messes up memory completely so the machine isn't in a
> stable state after the crash.
> It seems that if my Wimp task claims more memory after
> starting up and then calls:
> system("Filer_OpenDir a_directory");
> some sort of corruption occurs as after I close my next
> two windows a crash occurs.
> This is happening on my Iyonix RISC OS 5.16 128MB consistantly.
> Increasing the Wimp slot seems to fix the problem.
> However I can't reproduce it on RISC OS 4.0.2 or RISC OS 5.19
> running on RPCEmu.
> I haven't even managed to create a smaller test program to
> reproduce the problem, so it may be something else.
> I was hoping someone who is familiar with the system() call
> code could have a look at its code to see if there is some
> edge case I may be hitting.

As long as your program isn't corrupting the memory pool, you shouldn't
get such a crash as you're describing.  It looks like if there is not
enough application memory free the system() implementation badly fails.
If that's the case it would be workwhile to get to the bottom of this
but as you can imagine we need a reproducable case because system()
implementation is quite complex.

Are you using the same WimpSlot size for reproducing on RO 4.02 and
RO 5.19 ? Make sure you're using (or not using) DA for reproducing as

> [...]
> P.S. As an aside I'm wondering about using Wimp_StartTask
> instead of a system call and was wondering if anyone knew
> if that is sensible or not.

If your program is already a Wimp task, yes, I think you can use

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