On Mar 17, 6:53*pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth goo...@markginsburg.com:
>
>
>
> > > perl -v
> > This is perl, v5.8.8 built for MSWin32-x86-multi-thread
> > ...
>
> > == Begin of test.pl ==
> > use strict;
> > use warnings;
>
> > my $pid;
>
> > LaunchHostname();
>
> > print "waiting for child $pid to complete...\n";
> > my $waitstat = waitpid($pid,0);
> > print "waitpid returned $waitstat\n";
> > exit;
>
> > sub LaunchHostname {
> > * * $pid = fork ();
> > * * if (!defined($pid)) {
> > * * * * die "Failed to fork: $!\n";
> > * * }
> > * * elsif ($pid == 0) {
> > * * * * # This is the child
> > * * * * exec('hostname.exe'); *# LINE 22
> > * * * * die "exec failed\n";
> > * * }
>
> Since you're on Win32, is there a good reason for using fork/exec rather
> than system(1, ...) or Win32:
rocess? fork on Win32 is a rather
> complicated emulation, and fork+exec ends up being a convoluted way of
> calling spawnvp(3). Since the whole fork API is only present on Win32
> for compatibility with Unix scripts, it's better to use the native
> method.
I was unaware that system() could be made to run asynchroneously.
Thank you for the excellent suggestion, but I don't think it will work
for my situation.
With the fork/exec, I am starting a GUI application and then
manipulating it in my perl code using Win32::GuiTest. This GUI
application MUST be run from a specified directory, so in my actual
perl program, I do a chdir() to that directory in the child process
before the child calls exec() make the child perl process become the
application. I don't think there is any way to do that using system
(1,...).
It is interesting to note that no errors occur when the perl program
is run directly. The errors occur only when I run the executable I've
created using pp. This makes me suspect that the problem may be
related to something in PAR:

acker.
I was able to work around the problem (in an non-portable way) by
using Win32:

rocess::Create() instead of fork/exec. Fortunately for
me, Win32:

rocess::Create() takes the working directory as in input
argument.
> > * * return;
> > }
> > == END of test.pl ==
>
> > > perl test.pl
> > waiting for child -3592 to complete...
> > fileserver123
> > waitpid returned -3592
>
> > > pp -o test.exe test.pl
>
> > > test.exe
> > waiting for child -1600 to complete...
> > fileserver123
> > Free to wrong pool fac720 not 8367c0 at script/test.pl line 22.
>
> 'Free to wrong pool' generally indicates a threading-related bug in
> either perl itself or some XS module. Presumably you can get rid of this
> be removing the fork, but there's still an underlying bug somewhere. A
> lot of these 'Free to wrong pool' bugs were fixed in 5.10, and I expect
> most of the fixes went into 5.8.9 as well.
>
> > When I execute test.exe, the above error message is accompanied by a
> > pop up indicating "test.exe has encountered a problem and needs to
> > close. *We are sorry for the inconvenience."
>
> > When I do all the above on a system with perl v5.10.0 installed, I do
> > not get the "Free to wrong pool" message but get a pop up that says:
> > 'The instruction at "0x2800cd70" referenced memory at "0x00000028".
> > The memory could not be "read"'.
>
> > Any ideas why I get these errors?
>
> Not this one, sorry. Can you successfully build and execute anything
> with pp? Can you reduce that test case at all and still provoke the bug?
> Are you able to build a copy of perl with debugging symbols and get a
> stack trace at the point of the crash?
>
> Ben