FAQ
We leak an SV every time Opcode::_safe_call_sv is called (yes, it's
*shocking* I know! *Dozens* of bytes right down the drain! ;-)

To have a "clean" %INC for a Safe partition, we save save_hash(PL_incgv).
This actually (after saving the hv) creates a new, blank hv in its
place.

Then, we fetch/create a new %INC and overwrite the hv left over from
the save_hash, without freeing it...thus the memory leak.

Here's a little patch to fix.

diff -uBb ext/Opcode/Opcode.xs-orig ext/Opcode/Opcode.xs
--- ext/Opcode/Opcode.xs-orig Tue Jan 9 08:01:12 2001
+++ ext/Opcode/Opcode.xs Tue Jan 9 08:08:40 2001
@@ -271,6 +271,7 @@

/* %INC must be clean for use/require in compartment */
save_hash(PL_incgv);
+ sv_free((SV*)GvHV(PL_incgv)); /* get rid of what save_hash gave us*/
GvHV(PL_incgv) = (HV*)SvREFCNT_inc(GvHV(gv_HVadd(gv_fetchpv("INC",TRUE,SVt_PVHV))));

PUSHMARK(SP);
--
Drexel University \V --Chuck Lane
======]---------->--------*------------<-------[===========
(215) 895-1545 _/ \ Particle Physics
FAX: (215) 895-5934 /\ /~~~~~~~~~~~ lane@duphy4.physics.drexel.edu

Search Discussions

  • Jarkko Hietaniemi at Jan 10, 2001 at 6:46 pm

    On Wed, Jan 10, 2001 at 01:23:02PM -0500, Charles Lane wrote:
    We leak an SV every time Opcode::_safe_call_sv is called (yes, it's
    *shocking* I know! *Dozens* of bytes right down the drain! ;-)
    On the behalf of the Society for the Avoidance of Wasted Bytes
    I would like to take this opportunity to thank you for your contribution.
    To have a "clean" %INC for a Safe partition, we save save_hash(PL_incgv).
    This actually (after saving the hv) creates a new, blank hv in its
    place.

    Then, we fetch/create a new %INC and overwrite the hv left over from
    the save_hash, without freeing it...thus the memory leak.

    Here's a little patch to fix.

    diff -uBb ext/Opcode/Opcode.xs-orig ext/Opcode/Opcode.xs
    --- ext/Opcode/Opcode.xs-orig Tue Jan 9 08:01:12 2001
    +++ ext/Opcode/Opcode.xs Tue Jan 9 08:08:40 2001
    Thanks, applied.
    @@ -271,6 +271,7 @@

    /* %INC must be clean for use/require in compartment */
    save_hash(PL_incgv);
    + sv_free((SV*)GvHV(PL_incgv)); /* get rid of what save_hash gave us*/
    GvHV(PL_incgv) = (HV*)SvREFCNT_inc(GvHV(gv_HVadd(gv_fetchpv("INC",TRUE,SVt_PVHV))));

    PUSHMARK(SP);
    --
    Drexel University \V --Chuck Lane
    ======]---------->--------*------------<-------[===========
    (215) 895-1545 _/ \ Particle Physics
    FAX: (215) 895-5934 /\ /~~~~~~~~~~~ lane@duphy4.physics.drexel.edu
    --
    $jhi++; # http://www.iki.fi/jhi/
    # There is this special biologist word we use for 'stable'.
    # It is 'dead'. -- Jack Cohen

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedJan 10, '01 at 6:22p
activeJan 10, '01 at 6:46p
posts2
users2
websiteperl.org

2 users in discussion

Charles Lane: 1 post Jarkko Hietaniemi: 1 post

People

Translate

site design / logo © 2021 Grokbase