Skip site navigation (1) Skip section navigation (2)

Re: backend crashing despite tsearch2 patch

From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: psql-mail(at)freeuk(dot)com
Cc: pgsql-general(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: backend crashing despite tsearch2 patch
Date: 2003-09-17 22:44:14
Message-ID: Pine.LNX.4.21.0309172324470.7239-200000@ponder.fairway2k.co.uk (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-patches
This replaces the previous patch in this thread.


On Wed, 17 Sep 2003, Nigel J. Andrews wrote:
> 
> On Wed, 17 Sep 2003 psql-mail(at)freeuk(dot)com wrote:
> 
> > > On Wed, 17 Sep 2003 psql-mail(at)freeuk(dot)com wrote:
> > > 
> > > > #0  SN_create_env (S_size=0, I_size=2, B_size=1) at api.c:6
> > > > 6           z->p = create_s();
> > > > (gdb) bt
> > > > #0  SN_create_env (S_size=0, I_size=2, B_size=1) at api.c:6
> > > > #1  0x20000000026be870 in SN_create_env (S_size=40770504, I_size=
> > > > 40509856,
> > > > B_size=1034) at api.c:6
> > >
> ...
> Having said that the z in the z->p = create_s() line mentioned as the place of
> the fault is the result of a calloc without checking for a null return from
> calloc. Here's a[nother simple] patch to fix that.
> 
> It's not going to fix whatever is putting you into the situation that makes
> calloc fail though. It'll just make the failure less disasterous.


Here's a slightly more paranoid patch, i.e. it checks all the allocations done
in the routine instead of just the specific instance from the stack trace the
previous patch checked.

On a matter of style, it's been a while since I've seriously considered cross
platform C. Is it the done thing to expect:

 int *i = (int *)calloc(1,sizeof(int));

to give the condition *i == 0 (assuming the memory allocation worked)?

Also, I've not tested the amended code since I don't know that much about the
configuration of tsearch2 and specifically what this snowball stuff
is. However, it builds for me and a test query didn't break. I'd appreciate if
someone could give the changes a quick once over for correctness and if someone
could actually test this (maybe pgsql-mail(at)freeuk(dot)com). In the meantime I'll
see if I can get the regression test to run.

-- 
Nigel J. Andrews

Attachment: tsearch2.patch
Description: text/plain (3.7 KB)

In response to

Responses

pgsql-patches by date

Next:From: Nigel J. AndrewsDate: 2003-09-17 23:03:22
Subject: Re: [PATCHES] backend crashing despite tsearch2 patch
Previous:From: Nigel J. AndrewsDate: 2003-09-17 21:26:11
Subject: Re: backend crashing despite tsearch2 patch

pgsql-general by date

Next:From: BenDate: 2003-09-17 22:50:57
Subject: Re: High-volume shop uses PostgreSQL
Previous:From: Andrew L. GouldDate: 2003-09-17 22:37:46
Subject: Re: High-volume shop uses PostgreSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group