Re: [HACKERS] initdb problems - Mailing list pgsql-hackers

From Keith Parks
Subject Re: [HACKERS] initdb problems
Date
Msg-id 199808261613.RAA01232@mtcc.demon.co.uk
Whole thread Raw
Responses Re: [HACKERS] initdb problems  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian <maillist@candle.pha.pa.us>

>
> > Hi All,
> >
> > My problems seem to be getting worse!!
> >
> > Yesterday I was only getting a crash when I tried to create a table.
> >
> > Today, with the latest from cvs I'm getting a crash on a simple select.
> >
> > Here's the backtrace:-
>
> OK, selects should be fixed now.  Also

Confirmed, selects are fine, thanks.

>
> select relname, attname,attalign from pg_class, pg_attribute, pg_type
> where atttypid = pg_type.oid and typname = 'name' and pg_class.oid =
> attrelid and attalign != 'd'
>
> now returns no rows, as it should.  Some tricky work, but they are all
> correct now.  Let's see if that fixes the Sparc problem.


Unfortunately not but... I'm seeing some strange things in gdb.
(apologies again for the wide post :-( )

Attaching to program `/usr/local/pgsql/bin/postmaster', process 5422
Reading symbols from /lib/libdl.so.1.8.3...done.
Reading symbols from /lib/libm.so.5.0.6...done.
Reading symbols from /usr/lib/libreadline.so.2.0...done.
Reading symbols from /lib/libtermcap.so.2.0.8...done.
Reading symbols from /usr/lib/libncurses.so.3.0...done.
Reading symbols from /lib/libc.so.5.3.12...done.
Reading symbols from /lib/ld-linux.so.1...done.
0xe00f59c4 in __read ()
(gdb) break DataFill
Breakpoint 1 at 0x26b34: file heaptuple.c, line 126.
(gdb) cont
Continuing.

Breakpoint 1, DataFill (data=0x1b8438 "", tupleDesc=0x160e30, value=0xefffcdf8,
    nulls=0xefffce48 ' ' <repeats 16 times>, "à\034 ", infomask=0x1b8430,
bit=0x0) at heaptuple.c:126
126             bits8      *bitP = 0;
(gdb)
Continuing.

Breakpoint 1, DataFill (data=0x1b1318 "", tupleDesc=0x160a70, value=0xefffccdc,
nulls=0xefffcce0 " \026\0160",
    infomask=0xefffca66, bit=0x0) at heaptuple.c:126
126             bits8      *bitP = 0;
(gdb)
Continuing.

Breakpoint 1, DataFill (data=0x160618 "", tupleDesc=0x1607b0, value=0xefffccdc,
nulls=0xefffcce0 " \026\0160",
    infomask=0xefffca66, bit=0x0) at heaptuple.c:126
126             bits8      *bitP = 0;
(gdb)
Continuing.

Breakpoint 1, DataFill (data=0x1b1220 "", tupleDesc=0x160610, value=0xefffce14,
nulls=0xefffce18 "",
    infomask=0xefffcb9e, bit=0x1b1218 "") at heaptuple.c:126
126             bits8      *bitP = 0;
(gdb) step
130             int                     numberOfAttributes = tupleDesc->natts;
(gdb)
127             int                     bitmask = 0;
(gdb)
133             if (bit != NULL)
(gdb)
135                     bitP = &bit[-1];
(gdb)
136                     bitmask = CSIGNBIT;
(gdb)
141             for (i = 0; i < numberOfAttributes; i++)
(gdb)
143                     if (bit != NULL)
(gdb)
145                             if (bitmask != CSIGNBIT)
(gdb)
149                                     bitP += 1;
(gdb)
150                                     *bitP = 0x0;
(gdb)
151                                     bitmask = 1;
(gdb)
154                             if (nulls[i] == 'n')
(gdb)
160                             *bitP |= bitmask;
(gdb)
163                     switch (att[i]->attlen)
(gdb) print att[i]->attlen
$1 = 4
(gdb) step
189                                     *(int32 *) data = (att[i]->attbyval ?
(gdb)
193                                     break;
(gdb)
141             for (i = 0; i < numberOfAttributes; i++)
(gdb)
143                     if (bit != NULL)
(gdb)
145                             if (bitmask != CSIGNBIT)
(gdb)
154                             if (nulls[i] == 'n')
(gdb)
160                             *bitP |= bitmask;
(gdb)
163                     switch (att[i]->attlen)
(gdb)
195                                     if (att[i]->attlen < sizeof(int32))
(gdb) print att[i]->attlen
$2 = 32
(gdb) step
198                                     if (att[i]->attalign == 'd')
(gdb)
200                                             data = (char *)
DOUBLEALIGN(data);
(gdb)
201                                             memmove(data,
DatumGetPointer(value[i]),
(gdb)
204                                     }
(gdb)
208                                             memmove(data,
DatumGetPointer(value[i]),
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0xe016e6b4 in _wordcopy_fwd_aligned ()

So the memmove() at line 201 gets executed OK, no SIGSEGV but how do we get
to line 208 and call the memmove() again!!

I'm sure I must be missing the obvious but...

194                             default:
195                                     if (att[i]->attlen < sizeof(int32))
196                                             elog(ERROR, "DataFill: attribute
%d has len %d",
197                                                      i, att[i]->attlen);
198                                     if (att[i]->attalign == 'd')
199                                     {
200                                             data = (char *)
DOUBLEALIGN(data);
201                                             memmove(data,
DatumGetPointer(value[i]),
202                                                             att[i]->attlen);
203                                             data += att[i]->attlen;
204                                     }
205                                     else
206                                     {
207                                             data = (char *) LONGALIGN(data);
208                                             memmove(data,
DatumGetPointer(value[i]),
209                                                             att[i]->attlen);
210                                             data += att[i]->attlen;
211                                     }
212                                     break;

Help,
Keith.


pgsql-hackers by date:

Previous
From: David Hartwig
Date:
Subject: Re: [HACKERS] Rules for 6.4 finished
Next
From: Keith Parks
Date:
Subject: Re: [HACKERS] Rules for 6.4 finished