Patch: backend clobber prevention

Eric Lambrecht eml at
Tue Dec 12 06:07:18 UTC 2006

Brad Fitzpatrick wrote:
> Eric,
> I think this is now fixed as well in svn, but from the other side of
> things?  (backends properly clear out their client reference now...)

We still get a crash:

> Running.
> beginning run
> crash log: Not an ARRAY reference at /usr/share/perl5/Perlbal/ line 223.

Our version might be ever so slightly different than what's in SVN.. 
that line corresponds to:

> # returns true if this ClientProxy is too many bytes behind the backend
> sub too_far_behind_backend {
>     my Perlbal::ClientProxy $self    = $_[0];
>     my Perlbal::BackendHTTP $backend = $self->{backend}   or return 0;
>     # if a backend doesn't have a service, it's a
>     # ReproxyManager-created backend, and thus it should use the
>     # 'buffer_size_reproxy_url' parameter for acceptable buffer
>     # widths, and not the regular 'buffer_size'.  this lets people
>     # tune buffers depending on the types of webservers.  (assumption
>     # being that reproxied-to webservers are event-based and it's okay
>     # to tie the up longer in favor of using less buffer memory in
>     # perlbal)
>     my $max_buffer = defined $backend->{service} ?
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here
>         $self->{service}->{buffer_size} :
>         $self->{service}->{buffer_size_reproxy_url};
>     return $self->{write_buf_size} > $max_buffer;
> }


> - Brad
> On Thu, 12 Oct 2006, Eric Lambrecht wrote:
>>I swear I sent this patch out a while ago, but it isn't in the latest
>>SVN perlbal code and it just bit us in the butt again, now that we're
>>updating to it.
>>There is a condition where a ClientProxy can be given a new Backend C,
>>but its old Backend B retains a reference to the ClientProxy. When the
>>Backend B is closed, it tries to null out the ClientProxy's reference to
>>the Backend B, but actually ends up clobbering the ClientProxy's
>>reference to Backend C. This results in a horrible memory leak when
>>you're serving up big files like we are.
>>Anyway.. the attached patch fixes it.

More information about the perlbal mailing list