Apache2/MP2/Parllel::ForkManager and Segmentation Faults

Apache2/MP2/Parllel::ForkManager and Segmentation Faults

am 26.08.2008 20:04:06 von eric.berg

..lots of them.

First off, let me thank Torsten for the help understanding some of the
environment issues with forking.

I have created a class for running external programs that will be a
little bit smart and a little bit configurable to allow processes to be
run by system() calls directly, IPC::Run3, which uses system, or by
=24r->spawn_proc_prog() under mod_perl and also it provides for setting
environment variables via Env::C or by using =24r->subprocess_env->set(
=24var =3D> =24vars->{$var=7D ) if running under Apache/mod_perl.

Ok, now I've got my programs forking with the proper environment, but
I'm experiencing numerous segfaults. Same request issued multiple times
and a good number of them result in segmentation faults. That would be
on the order of once every other request, where each request could fork
about 7 or 8 times. =20

We're using DBI here as well, and I understand that there were related
issues with pre 1.3 versions of DBI.

I instantiate the ForkManager, and get into the loop, print out a
message right before I do my '=24pm->start and next;', and then I get
this:

=5BTue Aug 26 13:56:37 2008=5D =5Bnotice=5D child pid 19991 exit signal
Segmentation fault (11)

From=20what I've been able to determine so far, this happens when forking
the first process after creating the ForkManager object.

I'm running:

RHE Linux
Apache/2.2.9 (Unix) DAV/2 mod_apreq2-20051231/2.6.0=20
mod_perl/2.0.4=20
Perl/v5.10.0=20
DBI 1.605

I've tried changing the numbers the prefork mpm to allow for more
Clients, more MaxSpareServers. My config isn't tuned at all as you can
see:

StartServers 5
MinSpareServers 5
MaxSpareServers 15
MaxClients 150
MaxRequestsPerChild 128

Any thoughts or questions? =20

Eric D. Berg
Lehman Brothers
> Fixed Income Research
> 745 7th Avenue, 15th floor
> New York, NY 10019
> Phone +1 212 526 8118
>=20
>=20
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - =
- - - - - - -

This message is intended only for the personal and confidential use of the =
designated recipient(s) named above. If you are not the intended =
recipient of this message you are hereby notified that any review, =
dissemination, distribution or copying of this message is strictly =
prohibited. This communication is for information purposes only and =
should not be regarded as an offer to sell or as a solicitation of an =
offer to buy any financial product, an official confirmation of any =
transaction, or as an official statement of Lehman Brothers. Email =
transmission cannot be guaranteed to be secure or error-free. Therefore, =
we do not represent that this information is complete or accurate and it =
should not be relied upon as such. All information is subject to change =
without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within =
this communication (including any attachments) is not intended or written =
to be used and cannot be used for the purpose of (i) avoiding U.S. tax =
related penalties or (ii) promoting, marketing or recommending to another =
party any transaction or matter addressed herein.

Re: Apache2/MP2/Parllel::ForkManager and Segmentation Faults

am 26.08.2008 20:11:30 von Perrin Harkins

On Tue, Aug 26, 2008 at 2:04 PM, Berg, Eric wrote:
> We're using DBI here as well

That's going to make forking a lot more complicated. You'll need to
close your DBI handles before you fork, or set InactiveDestroy on
them. You need to open new ones in the forked process to do any DBI
work.

If you strip out the DBI stuff from the forked processes, does it
still segfault?

- Perrin

RE: Apache2/MP2/Parllel::ForkManager and Segmentation Faults

am 26.08.2008 20:28:38 von eric.berg

I'm using Apache::DBI.

I stripped out calls to code that use DBI and it still segfaults.

I've gone into the code and made sure that any method that does a DBI
call also uses =24dbh->disconnect;

Eric

> -----Original Message-----
> From: pharkins=40gmail.com =5Bmailto:pharkins=40gmail.com=5D On=20
> Behalf Of Perrin Harkins
> Sent: Tuesday, August 26, 2008 2:12 PM
> To: Berg, Eric
> Cc: modperl=40perl.apache.org; dlux=40kapu.hu
> Subject: Re: Apache2/MP2/Parllel::ForkManager and Segmentation Faults
>=20
> On Tue, Aug 26, 2008 at 2:04 PM, Berg, Eric=20
> wrote:
> > We're using DBI here as well
>=20
> That's going to make forking a lot more complicated. You'll need to
> close your DBI handles before you fork, or set InactiveDestroy on
> them. You need to open new ones in the forked process to do any DBI
> work.
>=20
> If you strip out the DBI stuff from the forked processes, does it
> still segfault?
>=20
> - Perrin
>=20
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - =
- - - - - - -

This message is intended only for the personal and confidential use of the =
designated recipient(s) named above. If you are not the intended =
recipient of this message you are hereby notified that any review, =
dissemination, distribution or copying of this message is strictly =
prohibited. This communication is for information purposes only and =
should not be regarded as an offer to sell or as a solicitation of an =
offer to buy any financial product, an official confirmation of any =
transaction, or as an official statement of Lehman Brothers. Email =
transmission cannot be guaranteed to be secure or error-free. Therefore, =
we do not represent that this information is complete or accurate and it =
should not be relied upon as such. All information is subject to change =
without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within =
this communication (including any attachments) is not intended or written =
to be used and cannot be used for the purpose of (i) avoiding U.S. tax =
related penalties or (ii) promoting, marketing or recommending to another =
party any transaction or matter addressed herein.

Re: Apache2/MP2/Parllel::ForkManager and Segmentation Faults

am 26.08.2008 20:35:23 von Perrin Harkins

On Tue, Aug 26, 2008 at 2:28 PM, Berg, Eric wrote:
> I'm using Apache::DBI.
>
> I stripped out calls to code that use DBI and it still segfaults.
>
> I've gone into the code and made sure that any method that does a DBI
> call also uses $dbh->disconnect;

With Apache::DBI, you actually need to call $dbh->SUPER::disconnect.
However, you would only need to do this right before forking, not on
every call.

- Perrin

RE: Apache2/MP2/Parllel::ForkManager and Segmentation Faults

am 26.08.2008 21:25:08 von eric.berg

Hey, Perrin.

My DBI calls are within the code that is executed in the loop. Not
before. Even so, I tried using =24dbh->super::disconnect(), and that had
no apparent affect. Still segfaulting.

I'm feeling like it's not the DBI stuff. Where else can I look?

Eric

> -----Original Message-----
> From: pharkins=40gmail.com =5Bmailto:pharkins=40gmail.com=5D On=20
> Behalf Of Perrin Harkins
> Sent: Tuesday, August 26, 2008 2:35 PM
> To: Berg, Eric
> Cc: modperl=40perl.apache.org; dlux=40kapu.hu
> Subject: Re: Apache2/MP2/Parllel::ForkManager and Segmentation Faults
>=20
> On Tue, Aug 26, 2008 at 2:28 PM, Berg, Eric=20
> wrote:
> > I'm using Apache::DBI.
> >
> > I stripped out calls to code that use DBI and it still segfaults.
> >
> > I've gone into the code and made sure that any method that=20
> does a DBI
> > call also uses =24dbh->disconnect;
>=20
> With Apache::DBI, you actually need to call =24dbh->SUPER::disconnect.
> However, you would only need to do this right before forking, not on
> every call.
>=20
> - Perrin
>=20
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - =
- - - - - - -

This message is intended only for the personal and confidential use of the =
designated recipient(s) named above. If you are not the intended =
recipient of this message you are hereby notified that any review, =
dissemination, distribution or copying of this message is strictly =
prohibited. This communication is for information purposes only and =
should not be regarded as an offer to sell or as a solicitation of an =
offer to buy any financial product, an official confirmation of any =
transaction, or as an official statement of Lehman Brothers. Email =
transmission cannot be guaranteed to be secure or error-free. Therefore, =
we do not represent that this information is complete or accurate and it =
should not be relied upon as such. All information is subject to change =
without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within =
this communication (including any attachments) is not intended or written =
to be used and cannot be used for the purpose of (i) avoiding U.S. tax =
related penalties or (ii) promoting, marketing or recommending to another =
party any transaction or matter addressed herein.

Re: Apache2/MP2/Parllel::ForkManager and Segmentation Faults

am 27.08.2008 17:18:14 von Perrin Harkins

On Tue, Aug 26, 2008 at 3:25 PM, Berg, Eric wrote:
> I'm feeling like it's not the DBI stuff. Where else can I look?

Your next step is probably to get a backtrace of the segfault and
figure out where it crashed.

- Perrin

RE: Apache2/MP2/Parllel::ForkManager and Segmentation Faults

am 28.08.2008 00:32:42 von eric.berg

Ok. I appreciate your help here, Perrin.

mod_backtrace gave me this:

=5BWed Aug 27 18:29:29 2008=5D pid 24456 mod_backtrace backtrace for sig 11
(thread =22pid=22 24456)
=5BWed Aug 27 18:29:29 2008=5D pid 24456 mod_backtrace main() is at 8062fb8
/home/pointsrv/apache/config/dev/modules/mod_backtrace.so=5B 0xa3fa43=5D
/home/erberg/public_html/work/point-www/aut(ap_run_fatal_exc eption+0x2e)
=5B0x8079ce2=5D
/home/erberg/public_html/work/point-www/aut=5B0x807b0a0=5D
/lib/tls/libpthread.so.0=5B0x5b9a98=5D
/home/pointsrv/apache/config/dev/modules/mod_perl.so(Perl_Pe rlIO_flush+0
x68)=5B0x116e648=5D
/home/pointsrv/apache/config/dev/modules/mod_perl.so(Perl_pp _fork+0x45)=5B
0x1149b55=5D
/home/pointsrv/apache/config/dev/modules/mod_perl.so(Perl_ru nops_standar
d+0x18)=5B0x1102fe8=5D
/home/pointsrv/apache/config/dev/modules/mod_perl.so(Perl_ca ll_sv+0x49a)
=5B0x110106a=5D
/home/pointsrv/apache/config/dev/modules/mod_perl.so(modperl _callback+0x
180)=5B0x10764f0=5D
/home/pointsrv/apache/config/dev/modules/mod_perl.so(modperl _callback_ru
n_handlers+0x35a)=5B0x1076b3a=5D
/home/pointsrv/apache/config/dev/modules/mod_perl.so(modperl _callback_pe
r_dir+0x53)=5B0x1076e83=5D
/home/pointsrv/apache/config/dev/modules/mod_perl.so(modperl _response_ha
ndler_cgi+0x11b)=5B0x107354b=5D
/home/erberg/public_html/work/point-www/aut(ap_run_handler+0 x32)=5B0x80735
6e=5D
/home/erberg/public_html/work/point-www/aut(ap_invoke_handle r+0xad)=5B0x80
73939=5D
/home/erberg/public_html/work/point-www/aut(ap_process_reque st+0x18d)=5B0x
807e669=5D
/home/erberg/public_html/work/point-www/aut=5B0x807c145=5D
/home/erberg/public_html/work/point-www/aut(ap_run_process_c onnection+0x
32)=5B0x8078e12=5D
/home/erberg/public_html/work/point-www/aut=5B0x80822c9=5D
/home/erberg/public_html/work/point-www/aut=5B0x808249e=5D
/home/erberg/public_html/work/point-www/aut=5B0x808252c=5D
=5BWed Aug 27 18:29:29 2008=5D pid 24456 mod_backtrace end of backtrace
=5BWed Aug 27 18:29:30 2008=5D =5Bnotice=5D child pid 24456 exit signal
Segmentation fault (11), possible coredump in /tmp

BTW, no core file was created in /tmp.

What do you think?

Eric=20

> -----Original Message-----
> From: pharkins=40gmail.com =5Bmailto:pharkins=40gmail.com=5D On=20
> Behalf Of Perrin Harkins
> Sent: Wednesday, August 27, 2008 11:18 AM
> To: Berg, Eric
> Cc: modperl=40perl.apache.org; dlux=40kapu.hu
> Subject: Re: Apache2/MP2/Parllel::ForkManager and Segmentation Faults
>=20
> On Tue, Aug 26, 2008 at 3:25 PM, Berg, Eric=20
> wrote:
> > I'm feeling like it's not the DBI stuff. Where else can I look?
>=20
> Your next step is probably to get a backtrace of the segfault and
> figure out where it crashed.
>=20
> - Perrin
>=20
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - =
- - - - - - -

This message is intended only for the personal and confidential use of the =
designated recipient(s) named above. If you are not the intended =
recipient of this message you are hereby notified that any review, =
dissemination, distribution or copying of this message is strictly =
prohibited. This communication is for information purposes only and =
should not be regarded as an offer to sell or as a solicitation of an =
offer to buy any financial product, an official confirmation of any =
transaction, or as an official statement of Lehman Brothers. Email =
transmission cannot be guaranteed to be secure or error-free. Therefore, =
we do not represent that this information is complete or accurate and it =
should not be relied upon as such. All information is subject to change =
without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within =
this communication (including any attachments) is not intended or written =
to be used and cannot be used for the purpose of (i) avoiding U.S. tax =
related penalties or (ii) promoting, marketing or recommending to another =
party any transaction or matter addressed herein.

RE: Apache2/MP2/Parllel::ForkManager and Segmentation Faults

am 28.08.2008 22:58:40 von eric.berg

Does anyone have time to take a look at this? I sure would appreciate
being able to move this forward and find a solution.

Thanks much in advance.

Eric

> -----Original Message-----
> From: Berg, Eric=20
> Sent: Wednesday, August 27, 2008 6:33 PM
> To: 'Perrin Harkins'
> Cc: modperl=40perl.apache.org
> Subject: RE: Apache2/MP2/Parllel::ForkManager and Segmentation Faults
>=20
> Ok. I appreciate your help here, Perrin.
>=20
> mod_backtrace gave me this:
>=20
> =5BWed Aug 27 18:29:29 2008=5D pid 24456 mod_backtrace backtrace=20
> for sig 11 (thread =22pid=22 24456)
> =5BWed Aug 27 18:29:29 2008=5D pid 24456 mod_backtrace main() is=20
> at 8062fb8
> /home/pointsrv/apache/config/dev/modules/mod_backtrace.so=5B 0xa3fa43=5D
>
/home/erberg/public_html/work/point-www/aut(ap_run_fatal_exc eption+0x2e)
=5B0x8079ce2=5D
> /home/erberg/public_html/work/point-www/aut=5B0x807b0a0=5D
> /lib/tls/libpthread.so.0=5B0x5b9a98=5D
>
/home/pointsrv/apache/config/dev/modules/mod_perl.so(Perl_Pe rlIO_flush+0
x68)=5B0x116e648=5D
>
/home/pointsrv/apache/config/dev/modules/mod_perl.so(Perl_pp _fork+0x45)=5B
0x1149b55=5D
>
/home/pointsrv/apache/config/dev/modules/mod_perl.so(Perl_ru nops_standar
d+0x18)=5B0x1102fe8=5D
>
/home/pointsrv/apache/config/dev/modules/mod_perl.so(Perl_ca ll_sv+0x49a)
=5B0x110106a=5D
>
/home/pointsrv/apache/config/dev/modules/mod_perl.so(modperl _callback+0x
180)=5B0x10764f0=5D
>
/home/pointsrv/apache/config/dev/modules/mod_perl.so(modperl _callback_ru
n_handlers+0x35a)=5B0x1076b3a=5D
>
/home/pointsrv/apache/config/dev/modules/mod_perl.so(modperl _callback_pe
r_dir+0x53)=5B0x1076e83=5D
>
/home/pointsrv/apache/config/dev/modules/mod_perl.so(modperl _response_ha
ndler_cgi+0x11b)=5B0x107354b=5D
>
/home/erberg/public_html/work/point-www/aut(ap_run_handler+0 x32)=5B0x80735
6e=5D
>
/home/erberg/public_html/work/point-www/aut(ap_invoke_handle r+0xad)=5B0x80
73939=5D
>
/home/erberg/public_html/work/point-www/aut(ap_process_reque st+0x18d)=5B0x
807e669=5D
> /home/erberg/public_html/work/point-www/aut=5B0x807c145=5D
>
/home/erberg/public_html/work/point-www/aut(ap_run_process_c onnection+0x
32)=5B0x8078e12=5D
> /home/erberg/public_html/work/point-www/aut=5B0x80822c9=5D
> /home/erberg/public_html/work/point-www/aut=5B0x808249e=5D
> /home/erberg/public_html/work/point-www/aut=5B0x808252c=5D
> =5BWed Aug 27 18:29:29 2008=5D pid 24456 mod_backtrace end of backtrace
> =5BWed Aug 27 18:29:30 2008=5D =5Bnotice=5D child pid 24456 exit=20
> signal Segmentation fault (11), possible coredump in /tmp
>=20
> BTW, no core file was created in /tmp.
>=20
> What do you think?
>=20
> Eric=20
>=20
> > -----Original Message-----
> > From: pharkins=40gmail.com =5Bmailto:pharkins=40gmail.com=5D On=20
> > Behalf Of Perrin Harkins
> > Sent: Wednesday, August 27, 2008 11:18 AM
> > To: Berg, Eric
> > Cc: modperl=40perl.apache.org; dlux=40kapu.hu
> > Subject: Re: Apache2/MP2/Parllel::ForkManager and=20
> Segmentation Faults
> >=20
> > On Tue, Aug 26, 2008 at 3:25 PM, Berg, Eric=20
> > wrote:
> > > I'm feeling like it's not the DBI stuff. Where else can I look?
> >=20
> > Your next step is probably to get a backtrace of the segfault and
> > figure out where it crashed.
> >=20
> > - Perrin
> >=20
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - =
- - - - - - -

This message is intended only for the personal and confidential use of the =
designated recipient(s) named above. If you are not the intended =
recipient of this message you are hereby notified that any review, =
dissemination, distribution or copying of this message is strictly =
prohibited. This communication is for information purposes only and =
should not be regarded as an offer to sell or as a solicitation of an =
offer to buy any financial product, an official confirmation of any =
transaction, or as an official statement of Lehman Brothers. Email =
transmission cannot be guaranteed to be secure or error-free. Therefore, =
we do not represent that this information is complete or accurate and it =
should not be relied upon as such. All information is subject to change =
without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within =
this communication (including any attachments) is not intended or written =
to be used and cannot be used for the purpose of (i) avoiding U.S. tax =
related penalties or (ii) promoting, marketing or recommending to another =
party any transaction or matter addressed herein.