Re: Foreign memory context read - Mailing list pgsql-hackers

From Vaibhav Kaushal
Subject Re: Foreign memory context read
Date
Msg-id 1306217967.2434.1.camel@localhost
Whole thread Raw
In response to Re: Foreign memory context read  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Indeed I was acting weird there. I had completely forgotten about the
bool pointer. Moreover, I actually got confused about the palloc0's
return type...whether it was a datum or a pointer to datum. Looked back
at the expansion and got it clear. 

Thanks a lot Mr. Tom. 

Regards,
Vaibhav

On Mon, 2011-05-23 at 09:58 -0400, Tom Lane wrote:
> Vaibhav Kaushal <vaibhavkaushal123@gmail.com> writes:
> > My mind started wandering after that error. Now, actually, i was trying to
> > do something like this:
> 
> > *last_result = palloc0(sizeof(Datum));
> > bool *isnnuull = true;
> > *last_result = slot_getattr(slot, num_atts, *isnnuull);
> 
> This seems utterly confused about data types.  The first line thinks
> that last_result is of type Datum ** (ie, pointer to pointer to Datum),
> since it's storing a pointer-to-Datum through it.  The third line
> however is treating last_result as of type Datum *, since it's storing
> a Datum (not pointer to Datum) through it.  And the second line is
> assigning "true" (a bool value) to a variable declared as pointer to
> bool, which you then proceed to incorrectly dereference while passing it
> as the last argument to slot_getattr.  The code will certainly crash on
> that deref, independently of the multiple other bugs here.
> 
> Recommendation: gcc is your friend.  Pay attention to the warnings it
> gives you.
> 
>             regards, tom lane




pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [BUGS] BUG #6034: pg_upgrade fails when it should not.
Next
From: Pavan Deolasee
Date:
Subject: Proposal: Another attempt at vacuum improvements