Skip Menu |

This queue is for tickets about the PAR-Packer CPAN distribution.

Report information
The Basics
Id: 29933
Status: resolved
Priority: 0/
Queue: PAR-Packer

People
Owner: Nobody in particular
Requestors: stanton [...] electric-cloud.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.976
Fixed in: (no value)



Subject: Errors from --clean packed application on HP-UX
I’m running into a problem on HP-UX with –clean and shared libraries that are packed with pp. What happens is that my program runs as expected, but then I see a bunch of errors as the program exits of the form: Error removing /var/tmp/par-stanton/temp-5778/yknNbRMWLy.sl at /opt/perl_5.8.8/lib/5.8.8/File/Temp.pm line 890. It appears that on HP-UX (11.11) you cannot unlink a shared library that is currently in use by a process. This file is locked until it is no longer mapped by any process. It turns out the same thing happens on Windows, but there is special code in PAR::Heavy::_dl_extract() to turn off the UNLINK attribute on Windows. The attached patch resolves the error message issue by disabling UNLINK on hpux and Windows. It also ensures that the temporary directory is completely removed on hpux and Windows by adding a fallback case to the END block in par.pl that attempts to remove the directory by exec'ing a sh/cmd script. Because the exec releases library handles, the script is allowed to delete all of the files. I have tested this patch on HP-UX (11.11), Solaris, Linux, Windows, and MacOS X.
Subject: diffs
Download diffs
application/octet-stream 2.4k

Message body not shown because it is not plain text.

Thanks, applied. I did one important change, though: If the cleanup-shell-script is run, it needs to return something "true". Otherwise, the tests fail. I couldn't fix it for WIndows, since I don't know the shell well enough. The "&&" between the commands there prohibits anything similar since the second rmdir is allowed to fail. I'll keep the ticket open in case you have a solution. my $cmd; if ($^O =~ m/win32/i) { $cmd = 'rmdir /q /s "' . $par_temp . '" >nul 2>nul && rmdir "' . $topdir . '" >nul 2>nul '; } else { $cmd = "rm -rf '" . $par_temp . "' >/dev/null 2>&1 ; rmdir '" . $topdir . "' >/dev/null 2>&1 ; true"; } Best regards, Steffen
Subject: RE: [rt.cpan.org #29933] Errors from --clean packed application on HP-UX
Date: Fri, 12 Oct 2007 10:54:34 -0700
To: <bug-PAR-Packer [...] rt.cpan.org>
From: "Scott Stanton" <stanton [...] electric-cloud.com>
Ah, it's worse than that. We actually need to exit with whatever the original exit code should have been. I think the only way to fix the windows version is to write out a temporary batch file that deletes itself as the last step. The following block attempts to correct the exit code problem on both platforms. I'm having problems with the test suite in general, so I'm not confident this passes the tests. END { if ($ENV{PAR_CLEAN}) { my $topdir = File::Basename::dirname($par_temp); unlink @tmpfile; if (rmdir $par_temp) { rmdir $topdir; } else { # Something went wrong unlinking the temporary directory. This # typically happens on platforms that disallow unlinking shared # libraries and executables that are in use. # # Try unlinking with an exec'ed shell command so the files are no # longer in use by this process. Note that this will terminate the # current process so no further END block processing will follow. my $cmd; if ($^O =~ m/win32/i) { my $tmp = new File::Temp( TEMPLATE => 'tmpXXXXX', DIR => File::Basename::dirname($topdir), SUFFIX => '.bat', UNLINK => 0 ); print $tmp " rmdir /q /s \"$par_temp\" rmdir \"$topdir\" rm \"" . $tmp->filename . "\" && exit $? "; $cmd = $tmp->filename . " >nul 2>nul "; close $tmp; } else { $cmd = "rm -rf '" . $par_temp . "' >/dev/null 2>&1 ; rmdir '" . $topdir . "' >/dev/null 2>&1; exit $?"; } outs(qq(Unable to remove all temp files, using exec($cmd))); exec($cmd); } } } Show quoted text
-----Original Message----- From: Steffen Müller via RT [mailto:bug-PAR-Packer@rt.cpan.org] Sent: Friday, October 12, 2007 3:27 AM To: Scott Stanton Subject: [rt.cpan.org #29933] Errors from --clean packed application on HP-UX <URL: http://rt.cpan.org/Ticket/Display.html?id=29933 > Thanks, applied. I did one important change, though: If the cleanup-shell-script is run, it needs to return something "true". Otherwise, the tests fail. I couldn't fix it for WIndows, since I don't know the shell well enough. The "&&" between the commands there prohibits anything similar since the second rmdir is allowed to fail. I'll keep the ticket open in case you have a solution. my $cmd; if ($^O =~ m/win32/i) { $cmd = 'rmdir /q /s "' . $par_temp . '" >nul 2>nul && rmdir "' . $topdir . '" >nul 2>nul '; } else { $cmd = "rm -rf '" . $par_temp . "' >/dev/null 2>&1 ; rmdir '" . $topdir . "' >/dev/null 2>&1 ; true"; } Best regards, Steffen
From: stanton [...] electric-cloud.com
I've attached a new patch based off revision 531 with some changes to try to avoid running the background shell script unless absolutely necessary. This patch also incorporates the changes needed to return the expected exit code. Also, I think you might be able to eliminate the @tmpfile variable now. It doesn't appear to be used by par.pl any more.
Download diffs2
application/octet-stream 1.9k

Message body not shown because it is not plain text.

From: stanton [...] electric-cloud.com
Ok, third time's the charm. The previous versions of this patch failed to preserve the exit code on Windows. I think a slight change in strategy is in order. Instead of using 'exec' to switch to a different program, I think it will work better if we spawn a background process that loops trying to delete the directory while the parent process exits in the normal manner. This should allow the parent process to finish doing its normal END handling and return with the expected exit code. Meanwhile the background process will become detached and finish the cleanup shortly after the parent exits. I think this new patch resolves both the normal cleanup issue and the locked file issue at the same time.
Download diffs3
application/octet-stream 2.7k

Message body not shown because it is not plain text.

Subject: Latest patch
From: stanton [...] electric-cloud.com
Arg! A chunk got dropped from the patch, so you'll need to add: eval { require Win32::Process }; to the block of requires around line 733.
On Thu Oct 18 17:28:27 2007, snstanton wrote: Show quoted text
> Arg! A chunk got dropped from the patch, so you'll need to add: > > eval { require Win32::Process }; > > to the block of requires around line 733.
Thanks, applied! (The rest of the patch, too.) What's blocking a PAR::Packer (and PAR) release now is only that there is a test failing* and I can't find enough time to investigate properly. Best regards, Steffen *The test being #33 of the 02pp tests in PAR::Packer.