Thread: Segmentation fault in psql

Segmentation fault in psql

From
"Patrick Bye (WFF)"
Date:
I'm getting a segmentation fault in psql in 7.3.2.  Last working version I
had was 7.2.4.  Here's the backtrace from the debugger.

> Program received signal SIGSEGV, Segmentation fault.
> 0x4017c8f8 in strlen () at ../sysdeps/generic/strlen.c:150
> 150     ../sysdeps/generic/strlen.c: No such file or directory.
> (gdb) bt
> #0  0x4017c8f8 in strlen () at ../sysdeps/generic/strlen.c:150
> #1  0x4017c5f8 in strdup () at strdup.c:49
> #2  0x412870 in SetVariable (space=0x443aa0, name=0x410a51 "ENCODING",
>     value=0xd105810 <Address 0xd105810 out of bounds>) at variables.c:107
> #3  0x41112c in main (argc=2, argv=0x0) at startup.c:227

I'm getting an invalid address back everytime pg_encoding_to_char is called.
I added a printf to the function (shown below) and then everything works
fine.  I think it has something to do with the optimizations but I don't
know where to change that.

const char *
pg_encoding_to_char(int encoding)
{
        if (PG_VALID_ENCODING(encoding))
        {
                pg_enc2name *p = &pg_enc2name_tbl[encoding];

                Assert(encoding == p->encoding);
                printf("p->name = %s\n",p->name);
                return p->name;
        }
        return "";
}

Patrick Bye
Programmer / Analyst
Westfair Foods Ltd.
pbye@westfair.ca
(403) 291-6538