Re: Foreign memory context read

From: Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Foreign memory context read
Date: 2011-05-23 14:51:38
Message-ID: BANLkTina2ZXKh1EDHSTGQFJbqw8a-Cqbng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Oh...well... I messed it up! Thanks a lot for that. The problem I think is
the bool pointer. Will check it soon.

--
Sent from my Android
On 23 May 2011 19:28, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2011-05-23 15:03:47 Re: Do you recommend 8.4 or 9.0 for basic usage?
Previous Message MauMau 2011-05-23 14:49:29 Re: Fw: [BUGS] BUG #6011: Some extra messages are output in the event log at PostgreSQL startup