Обсуждение: pg_dumpall segfault
============================================================================ POSTGRESQL BUG REPORT TEMPLATE ============================================================================ Your name : Nick Eskelinen Your email address : nickesk@cs.bu.edu System Configuration --------------------- Architecture (example: Intel Pentium) : UltraSparc Operating System (example: Linux 2.0.26 ELF) : Solaris 8 PostgreSQL version (example: PostgreSQL-7.3.2): PostgreSQL-7.3.2 Compiler used (example: gcc 2.95.2) : gcc 3.2.2 Please enter a FULL description of your problem: ------------------------------------------------ pg_dumpall segfaults when trying to dump group information. Postmaster and pg_dump run fine in this installation. Output from gdb --------------- (gdb) r -U postgres Starting program: /fs/cs-db/local/postgresql-7.3.2/bin/pg_dumpall -U postgres Password: -- -- PostgreSQL database cluster dump -- \connect "template1" -- -- Users -- [user information] -- -- Groups -- DELETE FROM pg_group; Program received signal SIGSEGV, Segmentation fault. 0xfef331bc in strlen () from /usr/lib/libc.so.1 (gdb) bt #0 0xfef331bc in strlen () from /usr/lib/libc.so.1 #1 0xfef861c8 in _doprnt () from /usr/lib/libc.so.1 #2 0xfef8833c in vsnprintf () from /usr/lib/libc.so.1 #3 0xff2386d0 in appendPQExpBuffer (str=0x273a8, fmt=0x14c00 "SELECT usename FROM pg_shadow WHERE usesysid = %s;") at pqexpbuffer.c:234 #4 0x00011c40 in dumpGroups (conn=0x27b00) at pg_dumpall.c:353 #5 0x000115b8 in main (argc=3, argv=0xffbef9e4) at pg_dumpall.c:196 (gdb) up 3 #3 0xff2386d0 in appendPQExpBuffer (str=0x273a8, fmt=0x14c00 "SELECT usename FROM pg_shadow WHERE usesysid = %s;") at pqexpbuffer.c:234 234 nprinted = vsnprintf(str->data + str->len, avail, (gdb) i lo args = 0xffbef8ac avail = 255 nprinted = 30 (gdb) p *str $1 = {data = 0x300b8 "SELECT usename FROM pg_shadow WHERE usesysid = ", len = 0, maxlen = 256} Please describe a way to repeat the problem. Please try to provide a concise reproducible example, if at all possible: ---------------------------------------------------------------------- All invocations of pg_dumpall result in a segmentation fault. If you know how this problem might be fixed, list the solution below: ---------------------------------------------------------------------
Nick Eskelinen <nickesk@cs.bu.edu> writes: > pg_dumpall segfaults when trying to dump group information. Hmm, you have any empty (member-less) groups? Looks like this loop needs a test at the top not the bottom ... regards, tom lane
Nick Eskelinen <nickesk@bu.edu> writes: > Ahh... as a matter of fact I do. Adding someone to this empty group > corrects the problem. Thought so. I've committed a fix if you need it: *** src/bin/pg_dump/pg_dumpall.c.orig Thu Mar 6 16:45:52 2003 --- src/bin/pg_dump/pg_dumpall.c Fri Mar 14 17:41:56 2003 *************** *** 327,333 **** val = strdup(PQgetvalue(res, i, 2)); tok = strtok(val, ",{}"); ! do { PGresult *res2; PQExpBuffer buf2 = createPQExpBuffer(); --- 327,333 ---- val = strdup(PQgetvalue(res, i, 2)); tok = strtok(val, ",{}"); ! while (tok) { PGresult *res2; PQExpBuffer buf2 = createPQExpBuffer(); *************** *** 347,353 **** tok = strtok(NULL, "{},"); } ! while (tok); printf("%s", buf->data); destroyPQExpBuffer(buf); --- 347,353 ---- tok = strtok(NULL, "{},"); } ! free(val); printf("%s", buf->data); destroyPQExpBuffer(buf); regards, tom lane
Ahh... as a matter of fact I do. Adding someone to this empty group corrects the problem. Thanks! Nick On Fri, Mar 14, 2003 at 05:32:42PM -0500, Tom Lane wrote: > Nick Eskelinen <nickesk@cs.bu.edu> writes: > > pg_dumpall segfaults when trying to dump group information. > > Hmm, you have any empty (member-less) groups? Looks like this loop > needs a test at the top not the bottom ... > > regards, tom lane