Change 16338 by jhi@alpha on 2002/05/02 12:37:22

        Integrate perlio;
        
        Fix the "PerlIO require leak". Snag was that clean_objs
        autoloaded DESTROY (needing IO) after known layers had
        been freed. Postpone layer list free to PerlIO_cleanup,
        rather than PerlIO_destruct. Tweak sequence in perl_destruct
        so that sv_undef is immortal till layer list is done with it.

Affected files ...

.... //depot/perl/perl.c#434 integrate
.... //depot/perl/perlio.c#169 integrate

Differences ...

==== //depot/perl/perl.c#434 (text) ====
Index: perl/perl.c
--- perl/perl.c.~1~     Thu May  2 06:45:05 2002
+++ perl/perl.c Thu May  2 06:45:05 2002
@@ -431,7 +431,7 @@
     FREETMPS;
 
     /* Need to flush since END blocks can produce output */
-    PerlIO_flush((PerlIO*)NULL); 
+    PerlIO_flush((PerlIO*)NULL);
 
     if (CALL_FPTR(PL_threadhook)(aTHX)) {
         /* Threads hook has vetoed further cleanup */
@@ -825,9 +825,6 @@
     SvANY(&PL_sv_no) = NULL;
     SvFLAGS(&PL_sv_no) = 0;
 
-    SvREFCNT(&PL_sv_undef) = 0;
-    SvREADONLY_off(&PL_sv_undef);
-
     {
         int i;
         for (i=0; i<=2; i++) {
@@ -846,6 +843,13 @@
     PerlIO_cleanup(aTHX);
 #endif
 
+    /* sv_undef needs to stay immortal until after PerlIO_cleanup
+       as currently layers use it rather than Nullsv as a marker
+       for no arg - and will try and SvREFCNT_dec it.
+     */
+    SvREFCNT(&PL_sv_undef) = 0;
+    SvREADONLY_off(&PL_sv_undef);
+
     Safefree(PL_origfilename);
     Safefree(PL_reg_start_tmp);
     if (PL_reg_curpm)

==== //depot/perl/perlio.c#169 (text) ====
Index: perl/perlio.c
--- perl/perlio.c.~1~   Thu May  2 06:45:05 2002
+++ perl/perlio.c       Thu May  2 06:45:05 2002
@@ -601,10 +601,6 @@
            f++;
        }
     }
-    PerlIO_list_free(aTHX_ PL_known_layers);
-    PL_known_layers = NULL;
-    PerlIO_list_free(aTHX_ PL_def_layerlist);
-    PL_def_layerlist = NULL;
 }
 
 void
@@ -2071,7 +2067,9 @@
 {
     int i;
 #ifdef USE_ITHREADS
-    PerlIO_debug("Cleanup %p\n",aTHX);
+    PerlIO_debug("Cleanup layers for %p\n",aTHX);
+#else
+    PerlIO_debug("Cleanup layers\n");
 #endif
     /* Raise STDIN..STDERR refcount so we don't close them */
     for (i=0; i < 3; i++)
@@ -2080,6 +2078,15 @@
     /* Restore STDIN..STDERR refcount */
     for (i=0; i < 3; i++)
        PerlIOUnix_refcnt_dec(i);
+
+    if (PL_known_layers) {
+       PerlIO_list_free(aTHX_ PL_known_layers);
+       PL_known_layers = NULL;
+    }
+    if(PL_def_layerlist) {
+       PerlIO_list_free(aTHX_ PL_def_layerlist);
+       PL_def_layerlist = NULL;
+    }
 }
 
 
End of Patch.

Reply via email to