Wednesday, 27 June 2012

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

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@aaug.net
ReportedBy: duncan_moore@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.

_______________________________________________
GCCSDK mailing list gcc@gccsdk.riscos.info
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK

No comments:

Post a Comment