Sunday, 6 May 2012

[gccsdk] [Bug 236] GCC 4.1.2 Rel 2 Dev 2012-05-01: fork/execvp/dup2 redirection problem

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

--- Comment #1 from Duncan Moore <duncan_moore@ntlworld.com> 2012-05-06 09:53:42 PDT ---
GCCSDK GCC 4.1.2 Release 2 Development 2012-05-05
SharedUnixLibrary 1.12
VRPC RISC OS 4.39

The 2012-05-05 test version has resolved the above issue.

However, with this code:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h> // open
#include <unistd.h> // close
#include <sys/wait.h> // wait WEXITSTATUS

//---------------------------------------------------------------------------
static int redirect(char* const cmd[],int file_in,int file_out,int file_err) {
pid_t childpid; // Child's pid.
int retval; // Child process return code.
int status; // Parent process return code.

childpid=fork(); // Create new process.
if (childpid==0) { // Child process.
fprintf(stdout,"child output 1\n");
fprintf(stderr,"child error 1\n");
if (file_in >=0) dup2(file_in, STDIN_FILENO); // Redirect standard input
if (file_out>=0) dup2(file_out,STDOUT_FILENO); // Redirect standard output
if (file_err>=0) dup2(file_err,STDERR_FILENO); // Redirect standard error
fprintf(stdout,"child output 2\n");
fprintf(stderr,"child error 2\n");
retval=execvp(cmd[0],cmd); // execvp() does not return on success.
return retval;
}
else if (childpid>0) { // Parent process.
wait(&status); // Wait for child to exit, and store its status.
fprintf(stdout,"parent output\n");
fprintf(stderr,"parent error\n");
return WEXITSTATUS(status);
} else { // fork() returns -1 on failure.
fprintf(stderr,"fork() error\n");
exit(1);
}
}
//---------------------------------------------------------------------------
int main(void) {
int file_in =open("file_in",O_RDONLY);
int file_out=open("file_out",O_WRONLY|O_CREAT);
int file_err=open("file_err",O_WRONLY|O_CREAT);

printf("start\n");

char* cmd[]={"gcc","-dumpmachine",0};
if (redirect(cmd,file_in,file_out,file_err)!=0) printf("system error\n");

close(file_in);
close(file_out);
close(file_err);

printf("end\n");

return 0;
}


what I think I should get is:

*test
start
child output 1
child error 1
parent output
parent error
end
*Type file_out
child output 2
arm-unknown-riscos
*Type file_err
child error 2
*

but what I actually get is:

*test
start
child output 1
child error 1
end
*Type file_out
child output 2
arm-unknown-riscos
parent output
parent error

*Type file_err
child error 2
*

i.e. the parent standard output and error output is being redirected to
file_out, when it should be going to the terminal. The two affected lines have
bytes 13 10 for the line terminator, rather than just 10.
If the execvp() line is replaced by exit(1), then the parent standard output
and error output go to the terminal as expected.

--
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

Saturday, 5 May 2012

Re: [gccsdk] Autobuilder and Scummvm



On 5 May 2012 22:25, Chris Gransden <chrisg@care4free.net> wrote:


I'll see if I can reproduce it. In the meantime as a workaround it you set
RO_SHAREDLIBS=no in your build-setvars file you should be able to build
just the static library.

Thanks Chris, that workaround got libtiff4 to build. If you want ssh access to my build machine, let me know.


It looks like libsdl1.2 needs a patch now! Here is the error;

Autobuilder: RISC OS patch: /home/robheaton/Downloads/gccsdk/autobuilder/libraries/sdl/libsdl1.2debian/include.os.p
patching file src/video/riscos/SDL_wimppoll.c
patching file src/video/riscos/SDL_riscosFullScreenVideo.c
Autobuilder: RISC OS patch: /home/robheaton/Downloads/gccsdk/autobuilder/libraries/sdl/libsdl1.2debian/SDL_riscosevents.p
patching file src/video/riscos/SDL_riscosevents.c
Autobuilder: RISC OS patch: /home/robheaton/Downloads/gccsdk/autobuilder/libraries/sdl/libsdl1.2debian/video.p.elf
patching file src/video/riscos/SDL_riscosASM.S
Hunk #1 FAILED at 1.
1 out of 2 hunks FAILED -- saving rejects to file src/video/riscos/SDL_riscosASM.S.rej
Autobuilder: Patches failed
Package libsdl1.2debian: ***Failure***
Dependency "libsdl1.2debian" failed for scummvm
Build for package "scummvm" failed

Re: [gccsdk] Autobuilder and Scummvm

In article
<CAHQJq4LJdfT1WNr+fGGcxYSrbiqUkEM2iYsLVTzG8iT_TMLrMw@mail.gmail.com>,
Robert Heaton <rob@robheaton.co.uk> wrote:
> On 5 May 2012 21:23, Chris Gransden <chrisg@care4free.net> wrote:

> >
> > That builds ok for me. What is your host operating system? I'm using Ubuntu
> > 12.04.
> >

> I'm using Ubuntu 12.04 too. 32bit version, just double checked and it's up
> to date.

I'll see if I can reproduce it. In the meantime as a workaround it you set
RO_SHAREDLIBS=no in your build-setvars file you should be able to build
just the static library.

Chris.


_______________________________________________
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

Re: [gccsdk] Autobuilder and Scummvm



On 5 May 2012 21:23, Chris Gransden <chrisg@care4free.net> wrote:

That builds ok for me. What is your host operating system? I'm using Ubuntu
12.04.

I'm using Ubuntu 12.04 too. 32bit version, just double checked and it's up to date.

Rob.

Re: [gccsdk] Autobuilder and Scummvm

In article
<CAHQJq4Ktb6mWAXMuhRm9x_SHcc0uRufUbaDD=wLRG32hEBxQ6g@mail.gmail.com>,
Robert Heaton <rob@robheaton.co.uk> wrote:

> /home/robheaton/Downloads/gccsdk/cross/lib/gcc/arm-unknown-riscos/4.6.4/../../../../arm-unknown-riscos/bin/ld:
> ../libtiff/.libs/libtiff.so: etext: invalid version 32739 (max 0)
> ../libtiff/.libs/libtiff.so: could not read symbols: Bad value
> collect2: ld returned 1 exit status
> make[2]: *** [libtiffxx.la] Error 1
> make[2]: Leaving directory
> `/home/robheaton/Downloads/gccsdk/build/libtiff4/tiff3-3.9.6/libtiff'
> make[1]: *** [all] Error 2
> make[1]: Leaving directory
> `/home/robheaton/Downloads/gccsdk/build/libtiff4/tiff3-3.9.6/libtiff'
> make: *** [all-recursive] Error 1
> Package libtiff4: ***Failure***
> Dependency "libtiff4" failed for libsdl1.2debian
> Dependency "libsdl1.2debian" failed for scummvm
> Build for package "scummvm" failed

That builds ok for me. What is your host operating system? I'm using Ubuntu
12.04.

Chris.

--

_______________________________________________
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

Re: [gccsdk] Autobuilder and Scummvm



On 5 May 2012 20:44, Chris Gransden <chrisg@care4free.net> wrote:

I've got a workaround for this. It's only failing on the man pages so safe
to ignore. You can temporarily rename the host rman to rman.orig then link
it to the true command. ln -s /bin/true rman.  It fools the script into
thinking rman has completed successfully. Just delete the link and rename
it back when the build has finished.


Cheers Chris!
It's now libtiff4 that wants to play up, yet again it's a different error to all the others;


/home/robheaton/Downloads/gccsdk/cross/lib/gcc/arm-unknown-riscos/4.6.4/../../../../arm-unknown-riscos/bin/ld: ../libtiff/.libs/libtiff.so: etext: invalid version 32739 (max 0)
../libtiff/.libs/libtiff.so: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libtiffxx.la] Error 1
make[2]: Leaving directory `/home/robheaton/Downloads/gccsdk/build/libtiff4/tiff3-3.9.6/libtiff'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/robheaton/Downloads/gccsdk/build/libtiff4/tiff3-3.9.6/libtiff'
make: *** [all-recursive] Error 1
Package libtiff4: ***Failure***
Dependency "libtiff4" failed for libsdl1.2debian
Dependency "libsdl1.2debian" failed for scummvm
Build for package "scummvm" failed
 

Re: [gccsdk] Autobuilder and Scummvm

In article
<CAHQJq4L7V1mB9tcuhbyWh-+8wdMGWRPu01vmB=cPWDxR2p3uGQ@mail.gmail.com>,
Robert Heaton <rob@robheaton.co.uk> wrote:

> RISC OS Cross installer mkdir: -p
> /home/robheaton/Downloads/gccsdk/build/libx11-6/package/share/man/man5
> /home/robheaton/Downloads/gccsdk/env/ro-install -m 644 Compose.5
> XCompose.5 '/home/robheaton/Downloads/gccsdk/env/share/man/man5'
> 1
> /bin/ln: `.' and `man3/.' are the same file
> macro "" not recognized -- ignoring
> rman: couldn't read in referenced file man5/Compose.5.
> Try cd'ing into ancestor directory that makes relative path valid first.
> make[3]: *** [install-filemanDATA] Error 1
> make[3]: Leaving directory
> `/home/robheaton/Downloads/gccsdk/build/libx11-6/libx11-1.4.4/man'
> make[2]: *** [install-am] Error 2
> make[2]: Leaving directory
> `/home/robheaton/Downloads/gccsdk/build/libx11-6/libx11-1.4.4/man'
> make[1]: *** [install-recursive] Error 1
> make[1]: Leaving directory
> `/home/robheaton/Downloads/gccsdk/build/libx11-6/libx11-1.4.4/man'
> make: *** [install-recursive] Error 1
> Package libx11-6: ***Failure***
> Dependency "libx11-6" failed for libsdl1.2debian
> Dependency "libsdl1.2debian" failed for scummvm
> Build for package "scummvm" failed

I've got a workaround for this. It's only failing on the man pages so safe
to ignore. You can temporarily rename the host rman to rman.orig then link
it to the true command. ln -s /bin/true rman. It fools the script into
thinking rman has completed successfully. Just delete the link and rename
it back when the build has finished.

Chris.

--

_______________________________________________
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