Discussion:
PAR packed code possible environmental failure
(too old to reply)
Martin A. Brooks
2014-10-27 20:16:26 UTC
Permalink
Hello

I am attempting to get a chunk of Perl dressed up as a Windows executable
using pp. This appears to be successful but the following warnings are
being emitted:

# Use of runtime loader module Module::Implementation detected. Results of
static scanning may be incomplete.
# Use of runtime loader module Module::Runtime detected. Results of static
scanning may be incomplete.

Indeed, when I run the .exe from a Windows command prompt, it runs just
fine.

However, in its final use, the program is being called from another piece
of software, a monitoring agent, which runs as a Windows service. It shows
the following error in its log file on execution:

PID 912: [Mon Oct 27 09:32:34 2014] PLUGIN RESULTS: exit=2; text=Can't
load
'C:\Windows\TEMP\par-4c41444353484e4153484353303124\cache-d9195d87261f3a64d0321e0b38ad4246ee284110\a900cac0.xs.dll'
for module Net::SSH2: load_file:The specified module could not be found at
C:/Strawberry/perl/lib/DynaLoader.pm line 193./ at
C:/Strawberry/perl/vendor/lib/PAR/Heavy.pm line 120./Compilation failed in
require at script/check_hnas.pl line 17./BEGIN failed--compilation aborted
at script/check_hnas.pl line 17.


To my amateur eye, this looks environmental but I confess to not having the
slightest idea what to do about it. I am hoping someone on this list would
be able to point me in the right direction. Any ideas?

Thanks in advance.

Regards

Martin A. Brooks
Roderich Schupp
2014-10-28 08:16:08 UTC
Permalink
Post by Martin A. Brooks
# Use of runtime loader module Module::Implementation detected. Results
of static scanning may be incomplete.
# Use of runtime loader module Module::Runtime detected. Results of
static scanning may be incomplete.
This might indicate a problem, but most likely yours has a different cause.
Post by Martin A. Brooks
Indeed, when I run the .exe from a Windows command prompt, it runs just
fine.
However, in its final use, the program is being called from another piece
of software, a monitoring agent, which runs as a Windows service. It shows
PID 912: [Mon Oct 27 09:32:34 2014] PLUGIN RESULTS: exit=2; text=Can't
load
'C:\Windows\TEMP\par-4c41444353484e4153484353303124\cache-d9195d87261f3a64d0321e0b38ad4246ee284110\a900cac0.xs.dll'
for module Net::SSH2
Net::SSH2 is an XS module, ie. in addition to pure Perl code it also
installs a DLL, .../Net/SSH2/SSH2.dll.
If I interpret Net::SSH2's Makefile.PL correctly this "glue" DLL is linked
against two "external"
(to the Perl ecosystem) DLLs, libssl32 and libeay32 (or similar). These are
missing from your
packed executable, causing the loading of SSH2.dll to fail if they can't be
found in the environment.
That's whythe packed executable works on the machine where you generated it
and fails on a machine without them installed.

PAR::Packer *never* packs such "external" DLLs, sorry - you must tell pp
explicitly (using the option --link).
Here's how - I assume that you have the program "objdump", which is the
case if
you're using Strawberry Perl or ActiveState Perl with the mingw32 ppm
installed:

1. Locate .../Net/SSH2/SSH2.dll in your Perl installation and run

objdump -ax .../Net/SSH2/SSH2.dll | grep "DLL Name"

(or the Windows equivalent for grep). Some of the DLLs listed might be
Windows system libraries,
these are irrelevant, look for names similar to libssl32.dll and
libeay32.dll.

2. Locate these two DLLs in your Perl installation and run objdump on them,
too.
It will probably turn out that one of these is linked against the other and
one
is linked against some zlib1.dll. Rinse and repeat.

3. You'll end up with a list of DLLs, foo.dll, bar.dll etc. Add them to
your pp command

pp --link foo.dll --link bar.dll ...

(since they should all be located in a directory that is in your PATH you
need not specify
full pathnames).

4. Check that pp has indeed packed them into the executable (currently it
will not even
complain if it can't find a --link DLL):

unzip -l your.exe

(the generated executable is also a zip file) and look for foo.dll etc in
the output.
They should all be found in a directory

shlib/<archname>

for the value of "archname" run

perl -MConfig -E "say $Config{archname}"


Cheers, Roderich
Martin A. Brooks
2014-10-28 10:44:17 UTC
Permalink
Hi Roderich,
Post by Roderich Schupp
Net::SSH2 is an XS module, ie. in addition to pure Perl code it also
installs a DLL, .../Net/SSH2/SSH2.dll.
If I interpret Net::SSH2's Makefile.PL correctly this "glue" DLL is linked
against two "external"
(to the Perl ecosystem) DLLs, libssl32 and libeay32 (or similar). These
are missing from your
packed executable, causing the loading of SSH2.dll to fail if they can't
be found in the environment.
That's whythe packed executable works on the machine where you generated it
and fails on a machine without them installed.
I was unclear. The packed executable works just fine when run at a
Windows command prompt on the target machine. The error occurs when the
executable is called by a service also running on the target machine, hence
my thinking that this is something environmental.


Regards

Martin A. Brooks

Loading...