Re: [APC-DEV] [PATCH] APC signals + coredump shared memory unmapping

[email protected] (Rasmus Lerdorf) Sun, 23 Dec 2007 08:01:40 -0800
Newsgroups php.apc.dev
Message-ID <[email protected]>
We have extremely bad experience with SEGV signal handlers seg faulting
themselves and sending the server into an infinite loop and thus taking
it down.  I don't mind the patch, but we should make sure people
understand the risks.

-Rasmus

Lucas Nealan wrote:
> Hi,
> 
> I would like to propose the attached patch against APC CVS HEAD. It provides
> the configurable ability to trap coredump related signals and unmap the APC
> shared memory segment while still calling any previously installed signal
> handlers. This feature would be enabled via a new apc ini entry,
> apc.coredump_unmap, which is defaulted to disabled.
> 
> Although this will technically work in production environments the
> functionality was engineered to solve a problem in shared development
> environments that require a really large apc shm size. In these environments
> when a coredump occurs in the SAPI, PHP or an extension the coredump file
> mayb be many gigabytes. If enough of these are generated concurrently,
> writing these large files may bring down a server.
> 
> All signal handling is done through sigaction and will be compiled out if
> autoconf HAVE_SIGACTION is not set (or it's overrided). The signal handling
> also uses SA_SIGINFO in order to maintain the ability to call previously
> registered handlers that also use this flag.
> 
> Signal handlers are registered per child in module RINIT since SAPIs like
> Apache may register their signal handlers after MINIT. Information about the
> previous handlers is stored in a module static. I believe this will be safe
> in ZTS builds since handlers will only be registered once in a non forking
> mode. If requested I will move these into APC globals.
> 
> As a note, although newer Linux kernels and other kernels may provide the
> facility to ignore various types of shared memory when generating a
> coredump, this type of setting does not allow the specificity that this
> patch provides. For example someone running Apache/PHP with a large APC
> cache may not want their mmaped Apache scoreboard excluded from their
> coredump files.
> 
> I've also made the patch available at the following url in case the
> attachment is problematic:
> 
> http://sizzo.org/~screen/patches/apc_signal_unmap.patch
> 
> -lucas
> 
> 
>