Computer VARSIZE_ANY(PTR) during debugging

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Computer VARSIZE_ANY(PTR) during debugging
Date: 2013-06-26 04:27:15
Message-ID: CA+HiwqGgD8HgbyBuoC1yQ36B2AB0mS8c_nJLu7WBXiaR1--3mg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

Is it possible to compute VARSIZE_ANY(PTR) during debugging?

---------------------------------------------------------
#define VARSIZE_ANY(PTR) \
(VARATT_IS_1B_E(PTR) ? VARSIZE_1B_E(PTR) : \
(VARATT_IS_1B(PTR) ? VARSIZE_1B(PTR) : \
VARSIZE_4B(PTR)))

#define VARATT_IS_1B_E(PTR) \
((((varattrib_1b *) (PTR))->va_header) == 0x80)
-----------------------------------------------------------

I tried using above expression, but it gives following:

(gdb) p ((((varattrib_1b *) ( tp+off ))->va_header) == 0x80)
No symbol "varattrib_1b" in current context.

Am I missing some gdb technique here using which I could find value of
this expression?

By the way, I am trying to find cause of a segmentation fault using a
core dump which occurred in slot_deform_tuple() of heaptuple.c in
8.4.2 (excuse me, but if this is unheard off, maybe there is an
issue). The segfault in question happens at line 1141:

off = att_align_pointer(off, thisatt->attalign, -1, tp + off);

char *tp; /* ptr to tuple data */
long off; /* offset in tuple data */

Disassembling seems to suggest (tp + off) is the faulting address.
Apparently, the segfault happens when 5th text column is being
extracted from a tuple (char(n), char(n), int4, char(n), text, ...).
Since, tp is fixed for the whole duration of loop and only off is
subject to change over iterations, it may have happened due to wrong
offset in this iteration.

Has anything of this kind been encountered/reported before?

--
Amit Langote

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2013-06-26 04:40:24 Re: Patch for fail-back without fresh backup
Previous Message Peter Eisentraut 2013-06-26 03:26:02 Re: updated emacs configuration