rschupp / PAR-Packer

(perl) Generate stand-alone executables, perl scripts and PAR files https://metacpan.org/pod/PAR::Packer
Other
48 stars 13 forks source link

[cperl] panic: attempt to copy freed scalar ... to ... at <embedded>/Tie/Hash/NamedCapture.pm [rt.cpan.org #133081] #34

Open rschupp opened 3 years ago

rschupp commented 3 years ago

Migrated from rt.cpan.org#133081 (status was 'new')

Requestors:

From rschupp@cpan.org on 2020-07-30 12:35:46 :

When building PAR::Packer with cperl (at least 5.28.2c, 5.30.0c) almost all test fail
with the same error message:

$ pp -o a.exe -E 0
panic: attempt to copy freed scalar 55c95f55e3e0 to 55c95f55dde0 at <embedded>/Tie/Hash/NamedCapture.pm line 7.
Compilation failed in require at -e line 140.

This is caused by cperl moving XSLoader from an external XSLoader.pm module directly into DynaLoader.so, hence patching XSLoader.pm via PAR::Filter::PatchContent doesn't work anymore.

As reminder to myself: looks like the following is happening:

1. pp runs (in PAR::Packer::_generate_output)
   parl -B -Oa.exe some.par

2. loads Tie/Hash/NamedCapture.pm with demangled name from the cache area

3. loads NamedCapture.so from the install location (_not_ the demangled copy from 
   the cache area though it is present) and calls boot_Tie__Hash__NamedCapture
   which panics

At that point (2) and (3) have worked successfully for lots of other "embedded" modules, 
so I dunno why Tie::Hash::NamedCapture behaves differently.
But the real problem is that dynamic loading of mangled DLLs from the cache area 
doesn't work, because intercepting dynamic loading doesn't work without the
patch to XSLoader.