[gccsdk] [Bug 240] New: fork() & prog$heap failure

bugzilla-daemon at riscos.info bugzilla-daemon at riscos.info
Wed Jun 27 04:29:18 PDT 2012


http://www.riscos.info/bugzilla3/show_bug.cgi?id=240

           Summary: fork() & prog$heap failure
           Product: GCC/GCCSDK
           Version: other
          Platform: Other
        OS/Version: RISC OS
            Status: NEW
          Severity: normal
          Priority: P1
         Component: C compiler
        AssignedTo: John.Tytgat at aaug.net
        ReportedBy: duncan_moore at ntlworld.com
   Estimated Hours: 0.0


GCCSDK GCC 4.1.2 Release 2 Development 2012-05-05
SharedUnixLibrary 1.12
VRPC RISC OS 4.39

#include <unistd.h>   // fork execvp _exit
#include <sys/wait.h> // wait WEXITSTATUS
#include <stdlib.h>   // exit
#include <stdio.h>    // printf
static int ro_system(char* const cmd[]) {
  int status;            // Child/Parent process return codes.
  pid_t childpid=fork(); // Create additional process.
  if (childpid==0) {     // Child process.
    status=execvp(cmd[0],cmd); // execvp() only returns on failure.
    _exit(status);
  }
  else if (childpid>0) { // Parent process.
    wait(&status);       // Wait for child to exit, and store its status.
    return WEXITSTATUS(status);
  } else {               // fork() returns -1 on failure.
    printf("fork() error\n");
    exit(1);
  }
}
int main(int argc,char** argv) {
  (void) argc;
  return ro_system(++argv);
}

This program fails when test$heap is set:

*UnSet test$heap
*UnSet test$heapmax
*test gcc -dumpmachine
arm-unknown-riscos
*Set test$heap ""
*test gcc -dumpmachine
fork() error
*Set test$heapmax 1
*test gcc -dumpmachine
fork() error

Replacing fork() by vfork() gives what I would expect:

*UnSet test$heap
*UnSet test$heapmax
*test gcc -dumpmachine
arm-unknown-riscos
*Set test$heap ""
*test gcc -dumpmachine
arm-unknown-riscos

-- 
Configure bugmail: http://www.riscos.info/bugzilla3/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.




More information about the gcc mailing list