Subject: [mp1] PerlFreshRestart, perl_reload_inc, segmentation fault (patch)
When using mod_perl-1.30 (with perl 5.8.5, apache 1.3.37) with "PerlFreshRestart On" (yes, dangerous), httpd gets a segmentation fault. Using valgrind, discovered that part of the problem is related to the way memory is used in perl_reload_inc() (src/modules/perl/perl_util.c): void perl_reload_inc(server_rec *s, pool *sp) ... 1 hv_iterinit(hash); 2 while ((entry = hv_iternext(hash))) { 3* ap_table_setn(reload, HeKEY(entry), "1"); 4 } 5 6 { 7 array_header *arr = ap_table_elts(reload); 8 table_entry *elts = (table_entry *)arr->elts; 9 SV *keysv = newSV(0); 10 for (i=0; i < arr->nelts; i++) { 11 sv_setpv(keysv, elts[i].key); 12 if (!(entry = hv_fetch_ent(hash, keysv, FALSE, 0))) { 13 MP_TRACE_g(fprintf(stderr, 14 "%s not found in %%INC\n", elts[i].ke y)); 15 continue; 16 } 17* hv_delete_ent(hash, keysv, G_DISCARD, 0); 18 MP_TRACE_g(fprintf(stderr, "reloading %s\n", elts[i].key)); 19* perl_require_pv(elts[i].key); 20 } 21 SvREFCNT_dec(keysv); 22 } at line 3, ap_table_setn() does make take a copy of the string (it uses the memory that is in the perl hash); at line 17, the hash entry is deleted (memory free'd), and at line 19, the value is used. Changing the ap_table_setn() to ap_table_set() fixes this particular problem. Hope this is useful, Michael