You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Michael Rendell <mi...@cs.mun.ca> on 2007/11/20 15:51:52 UTC
[mp1] PerlFreshRestart, perl_reload_inc, segmentation fault (patch)
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
Re: [mp1] PerlFreshRestart, perl_reload_inc, segmentation fault (patch)
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Michael Rendell wrote:
> 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.
Yup, verified this one.
> 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):
>
> [...]
>
> Changing the ap_table_setn() to ap_table_set() fixes this particular
> problem.
>
> Hope this is useful,
Very much so! Thanks a lot.
Committed revision 600439.
--
Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/