Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAR::Packer-1.055 fails on most non-rs6000 platforms #66

Closed
GlennWood opened this issue Aug 15, 2022 · 9 comments
Closed

PAR::Packer-1.055 fails on most non-rs6000 platforms #66

GlennWood opened this issue Aug 15, 2022 · 9 comments

Comments

@GlennWood
Copy link

GlennWood commented Aug 15, 2022

Roderich, you fixed a problem with --clean option on rs6000 platforms with v1.055 (#62). It turns out another team here attempted to pack a different program using 1.055 and the packed executable fails on other platforms, e.g. LinuxR_x86. Without the --clean option, or by using 1.054, they report that it will work properly.

I have duplicated their problem; I get the following running the packed executable:

./nbdeployutil --gather --traditional --background
/tmp/nbdeployutil_2zBhJ
Can't load '/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/5b38968d.so' for module IO: /tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/5b38968d.so: cannot open shared object file: No such file or directory at <embedded>/DynaLoader.pm line 193.
 at <embedded>/PAR/Heavy.pm line 95.
Compilation failed in require at <embedded>/IO/Handle.pm line 268.
BEGIN failed--compilation aborted at <embedded>/IO/Handle.pm line 268.
Compilation failed in require at <embedded>/IO/Seekable.pm line 100.
BEGIN failed--compilation aborted at <embedded>/IO/Seekable.pm line 100.
Compilation failed in require at <embedded>/IO/File.pm line 132.
BEGIN failed--compilation aborted at <embedded>/IO/File.pm line 132.
Compilation failed in require at -e line 142.

Can you look into this, please?

@rschupp
Copy link
Owner

rschupp commented Aug 16, 2022

I can't reproduce this with the following simple "hello, world" using --clean

$ pp --clean -o clean.exe -E 'say "PAR::Packer = ${PAR::Packer::VERSION}"; say "PAR_TEMP = $ENV{PAR_TEMP}";'
$ ./clean.exe 
PAR::Packer = 1.055
PAR_TEMP = /tmp/par-726f646572696368/cache-5883d6b770f9019ef9183f1dbe84d16bcaacee83
$ ls -ld /tmp/par-726f646572696368/cache-5883d6b770f9019ef9183f1dbe84d16bcaacee83
/bin/ls: cannot access '/tmp/par-726f646572696368/cache-5883d6b770f9019ef9183f1dbe84d16bcaacee83': No such file or directory

(so clean.exe works and cleaning also works).

Can't load '/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/5b38968d.so' for module IO: /tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/5b38968d.so: c: No such file or directory at <embedded>/DynaLoader.pm line 193.

Run your test under strace and check whether the file in the error message really doesn't exist or DynaLoader is lying to us.

@GlennWood
Copy link
Author

GlennWood commented Aug 16, 2022

strace output attached
While getting this, I tried executing it multiple times: and got a few different results. Here is the output of those:

[gwood@vraNB6802 ~]$ cd tmp

[gwood@vraNB6802 tmp]$ ../nbdeployutil --gather --traditional --background
/tmp/nbdeployutil_yk__R
Error writing "/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/5e65e3d1.pm.153901": No such file or directory at -e line 521.

[gwood@vraNB6802 tmp]$ ../nbdeployutil --gather --traditional --background
/tmp/nbdeployutil_bCyFh
Error writing "/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/95c1e7e6.pm.153911": No such file or directory at -e line 521.
Compilation failed in require at <embedded>/Carp/Heavy.pm line 3.
BEGIN failed--compilation aborted at <embedded>/Carp/Heavy.pm line 3.
Compilation failed in require at -e line 139.

[gwood@vraNB6802 tmp]$ ../nbdeployutil --gather --traditional --background
/tmp/nbdeployutil_m9jp5
Error writing "/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/5e65e3d1.pm.153932": No such file or directory at -e line 521.

[gwood@vraNB6802 tmp]$ ../nbdeployutil --gather --traditional --background
/tmp/nbdeployutil_q74C3
Error writing "/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/3b86428e.pm.153943": No such file or directory at -e line 521.

[gwood@vraNB6802 tmp]$ ../nbdeployutil --gather --traditional --background
/tmp/nbdeployutil_c_QK9
Error writing "/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/5e65e3d1.pm.153949": No such file or directory at -e line 521.

[gwood@vraNB6802 tmp]$ ../nbdeployutil --gather --traditional --background
/tmp/nbdeployutil_bvr1S
Can't load '/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/a2930ce9.so' for module Compress::Raw::Zlib: /tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/a2930ce9.so: cannot open shared object file: No such file or directory at <embedded>/DynaLoader.pm line 193.
 at <embedded>/PAR/Heavy.pm line 95.
Compilation failed in require at <embedded>/Archive/Zip.pm line 9.
BEGIN failed--compilation aborted at <embedded>/Archive/Zip.pm line 9.
Compilation failed in require at -e line 145.

[gwood@vraNB6802 tmp]$ ../nbdeployutil --gather --traditional --background
/tmp/nbdeployutil_Ff3Wb
Error writing "/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/95c1e7e6.pm.154006": No such file or directory at -e line 521.
Compilation failed in require at <embedded>/Carp/Heavy.pm line 3.
BEGIN failed--compilation aborted at <embedded>/Carp/Heavy.pm line 3.
Compilation failed in require at -e line 139.

[gwood@vraNB6802 tmp]$ ../nbdeployutil --gather --traditional --background
/tmp/nbdeployutil_XjpSj
Can't load '/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/6dacc4c4.so' for module Encode: /tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1/6dacc4c4.so: cannot open shared object file: No such file or directory at <embedded>/DynaLoader.pm line 193.
 at <embedded>/PAR/Heavy.pm line 95.
BEGIN failed--compilation aborted at <embedded>/Encode.pm line 13.
Compilation failed in require at <embedded>/Archive/Zip/Archive.pm line 12.
BEGIN failed--compilation aborted at <embedded>/Archive/Zip/Archive.pm line 12.
Compilation failed in require at <embedded>/Archive/Zip.pm line 316.
Compilation failed in require at -e line 145.

par-packer-issue-66.strace.out.log
par-packer-issue-66.strace.err.log

@rschupp
Copy link
Owner

rschupp commented Aug 16, 2022

strace.err.log (BTW: please use strace -o trace_log ... to capture the strace log) starting with line 17192 shows that "someone" is deleting the files beneath the cache area (/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1).
That is not the cleanup done by PAR::Packer (actually par_rmtmpdir() in myldr/mktmpdir), as the latter doesn't use chdir. This cleanup actually starts at line 19531.
So "someone" must be the packed script, right?

Also the log contains two clone calls and I can't see what the new threads are doing -use strace -f ... to trace thru clone/fork. A good idea is also strace -s 200 ... so that we can see more of the content of write and read calls.

At the end of strace.err.log you can see actual error messages from perl, but I don't see the writes that produce them (nor do I see the failing syscalls), this must actually happen in the cloned threads...

@rschupp
Copy link
Owner

rschupp commented Aug 17, 2022

"someone" is deleting the files beneath the cache area (/tmp/par-67776f6f64/cache-cb5707b8810b800fc0a1a76b15d413c2ada257e1).

This traverse-and-delete looks as if produced by File::Path::remove_tree (AKA rmtree)... In the PAR ecosystem only PAR::Dist uses File::Path::remove_tree.

@GlennWood
Copy link
Author

Here is the strace log with -f. It adds 25% more lines; quite a tangle. I'll be perusing it, but if anything leaps out at you, let me know. TIA

nbdeployutil.strace.log

@rschupp
Copy link
Owner

rschupp commented Aug 22, 2022

OK, I see what's going on... You invoke (via system()) nbdeployutil (a packed executable) from nbdeployutil itself.
Both use the same cache directory (/tmp/par-USER/cache-SHA1) and have --clean set. So when the "inner" nbdeployutil finishes it will remove the cache directory. The problem is that executables packed with --clean should have cache directories of the form /tmp/par-USER/temp-PID, i.e. different directories for each invocation.
That is an unexpected side effect of my fix for #62: it moved the information "this executable was packed with --clean" from
patching the boot executable to the file META.yml in the zip part of the executable. It will be honored alright, i.e. the cache directory will be removed, but at the time we look in the zip it's too late, the wrong type of cache directory has already been created.
The information must somehow be extracted by the boot executable itself (which creates the cache directory). My idea is to encode that in the "Ending section" (see man par.pl, "Stand-alone executable format"), but this requires major surgery. So it's gonna take a while.

@rschupp
Copy link
Owner

rschupp commented Aug 28, 2022

@GlennWood Please try the version from branch "par_clean". It's not based on current broken "master", but goes back to #62 (hence should get right the ephemeral vs persistent cache directory when used with/without --clean).
I'm esp. curious whether it passes your minimal-viable-test in #62 (comment)
If it still fails, please post

  • the packed executable hello
  • the file hello.truss obtained from running truss -a -e -f -o hello.truss ./hello

@GlennWood
Copy link
Author

OK minimal-viable-test in #62 (comment), with or without --clean

@rschupp
Copy link
Owner

rschupp commented Sep 5, 2022

@GlennWood Thanks for testing.
I just released a slightly edited version of that branch as 1.056 to CPAN.

rschupp added a commit that referenced this issue Sep 5, 2022
…header is too large.""

This reverts commit 45f2cd5.

See #66 - PAR_CLEAN is set too late: at this point PAR_TEMP has already
been set (and populated) to a persistent cache directory
(/tmp/par-USER/cache-SHA1) instead of an ephemeral one (/tmp/par-USER/temp-PID).
@rschupp rschupp closed this as completed in 88b57cd Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants