nayakgi / perl-compiler

Automatically exported from code.google.com/p/perl-compiler
Other
0 stars 0 forks source link

savepvn vs PerlMemShared_malloc: cop_warnings, PMOP.op_pv #362

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Use the right allocator for the system provided free.
With DEBUGGING (or USE_MYMALLOC) savepvn will return different pointers than 
the ones malloced, and 
there are several free methods being used. Use the matching ones.

cop.cop_warnings and PMOP.op_pv are freed with PerlMemShared_free (i.e. the 
system free), 
but the code uses savepvn, which might add PERL_MEMORY_DEBUG_HEADER_SIZE to the 
returned ptr.

Original issue reported on code.google.com by reini.urban on 20 Jul 2014 at 4:10

GoogleCodeExporter commented 9 years ago
The pmtrans table also, but this is stored in op_pv.
sv_debug_file also needs to be allocated with savesharedpv, not savepv

Original comment by reini.urban on 20 Jul 2014 at 4:16

GoogleCodeExporter commented 9 years ago
work is  done in the branch `malloc-i362`

Original comment by reini.urban on 21 Jul 2014 at 1:27

GoogleCodeExporter commented 9 years ago
Fixed with commit 384b0beee87311781e60bccca19dad98e9f69ede
Author: Reini Urban <rurban@cpanel.net>
Date:   Sun Jul 20 12:35:15 2014 -0500

    C 1.49_04: Use system malloc for system free'd data

    change cop_warnings, PMOP->op_pv, sv_debug_file,
    needed for certain DEBUGGING options.
    use savesharedpvn for PerlMemShared_* memory, backport
    savesharedpvn for <5.8.9

    With DEBUGGING savepvn returns ptr + PERL_MEMORY_DEBUG_HEADER_SIZE
    which is not the address which will be freed, eg. in cop_free.

    Also fixes Attribute::Handler free errors. See issue #362

Original comment by reini.urban on 21 Jul 2014 at 6:20

GoogleCodeExporter commented 9 years ago

Original comment by reini.urban on 21 Jul 2014 at 6:20