Обсуждение: Segfault Exiting psql

Поиск
Список
Период
Сортировка

Segfault Exiting psql

От
David Wheeler
Дата:
PostgreSQL hackers:

8.0.3 is working great for me on Mac OS X Tiger, but I do get a  
segfault every time I exit pssql:

psql(7466) malloc: *** error for object 0x1806600: incorrect checksum  
for freed object - object was probably modified after being freed,  
break at szone_error to debug
psql(7466) malloc: *** set a breakpoint in szone_error to debug
zsh: segmentation fault  /usr/local/pgsql/bin/psql -U postgres -d sharky

Anyone seen this before? Compiled with gcc 4.0 (Apple's).

Thanks!

David


Re: Segfault Exiting psql

От
Tom Lane
Дата:
David Wheeler <david@justatheory.com> writes:
> 8.0.3 is working great for me on Mac OS X Tiger, but I do get a  
> segfault every time I exit pssql:

> psql(7466) malloc: *** error for object 0x1806600: incorrect checksum  
> for freed object - object was probably modified after being freed,  
> break at szone_error to debug
> psql(7466) malloc: *** set a breakpoint in szone_error to debug
> zsh: segmentation fault  /usr/local/pgsql/bin/psql -U postgres -d sharky

> Anyone seen this before? Compiled with gcc 4.0 (Apple's).

Hmm, I don't see that symptom, but I do see some strange stuff building
PG CVS tip on a fully-up-to-date (10.4.2) OS X machine.  First off,
a lot of duplicate-symbol build warnings, eg while linking pg_dump:

usr/bin/ld: warning multiple definitions of symbol _pg_toupper
../../../src/port/libpgport.a(pgstrcasecmp.o) definition of _pg_toupper in section (__TEXT,__text)
../../../src/interfaces/libpq/libpq.dylib(pgstrcasecmp.o) definition of _pg_toupper
/usr/bin/ld: warning multiple definitions of symbol _pg_strncasecmp
../../../src/port/libpgport.a(pgstrcasecmp.o) definition of _pg_strncasecmp in section (__TEXT,__text)
../../../src/interfaces/libpq/libpq.dylib(pgstrcasecmp.o) definition of _pg_strncasecmp
/usr/bin/ld: warning multiple definitions of symbol _pg_strcasecmp
../../../src/port/libpgport.a(pgstrcasecmp.o) definition of _pg_strcasecmp in section (__TEXT,__text)
../../../src/interfaces/libpq/libpq.dylib(pgstrcasecmp.o) definition of _pg_strcasecmp
/usr/bin/ld: warning multiple definitions of symbol _pg_tolower
../../../src/port/libpgport.a(pgstrcasecmp.o) definition of _pg_tolower in section (__TEXT,__text)
../../../src/interfaces/libpq/libpq.dylib(pgstrcasecmp.o) definition of _pg_tolower
/usr/bin/ld: warning multiple definitions of symbol _pqStrerror
../../../src/port/libpgport.a(thread.o) definition of _pqStrerror in section (__TEXT,__text)
../../../src/interfaces/libpq/libpq.dylib(thread.o) definition of _pqStrerror
/usr/bin/ld: warning multiple definitions of symbol _pqGetpwuid
../../../src/port/libpgport.a(thread.o) definition of _pqGetpwuid in section (__TEXT,__text)
../../../src/interfaces/libpq/libpq.dylib(thread.o) definition of _pqGetpwuid

This noise wasn't there ever before; I do not know if it's just that
Apple's tools got pickier recently, or if we've broken something.

Second, at exit from an interactive psql session,

regression=# \q
could not save history to file "/Users/tgl/.psql_history": Invalid argument
$

The file is written, but it seems not to contain the expected contents.
This might be the fault of my not-so-up-to-date readline library.
Not sure if your symptom could also be blamed on readline --- have you
tried getting a stack trace from the crash?
        regards, tom lane


Re: Segfault Exiting psql

От
David Wheeler
Дата:
On Jul 15, 2005, at 4:55 PM, Tom Lane wrote:

> This noise wasn't there ever before; I do not know if it's just that
> Apple's tools got pickier recently, or if we've broken something.

I think they're new to Tiger, because I saw some warnings I ignored  
when I built Pg.

> Second, at exit from an interactive psql session,
>
> regression=# \q
> could not save history to file "/Users/tgl/.psql_history": Invalid  
> argument
> $
>
> The file is written, but it seems not to contain the expected  
> contents.
> This might be the fault of my not-so-up-to-date readline library.
> Not sure if your symptom could also be blamed on readline --- have you
> tried getting a stack trace from the crash?

No. I'm using the readline that comes with Tiger, FWIW. If you tell  
me how to create a stack trace, I'll post it somewhere for you to  
see. I don't know C, myself.

Thanks!

David


Re: Segfault Exiting psql

От
David Wheeler
Дата:
On Jul 15, 2005, at 5:13 PM, David Wheeler wrote:

> No. I'm using the readline that comes with Tiger, FWIW. If you tell  
> me how to create a stack trace, I'll post it somewhere for you to  
> see. I don't know C, myself.

Didn't see a reply to this, but if it makes a difference, I just  
learned that the readline library that comes with Tiger (no prior  
version of Mac OS X included readline) is not GNU readline.  
readline.h starts with:

/*      $NetBSD: readline.h,v 1.11 2004/01/17 17:57:40 christos Exp  
$   */

/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.

Might this be the source of the segfaults when exiting psql?

Best,

David



Re: Segfault Exiting psql

От
Tom Lane
Дата:
Awhile back I wrote:
> Hmm, I don't see that symptom, but I do see some strange stuff building
> PG CVS tip on a fully-up-to-date (10.4.2) OS X machine.
> ...
> Second, at exit from an interactive psql session,

> regression=# \q
> could not save history to file "/Users/tgl/.psql_history": Invalid argument
> $

I looked into this and found that psql is preferentially linking to the
version of libedit that Apple supplies (even though I had GNU readline
in /usr/local/lib).  And as best I can tell, in libedit the
write_history() function returns the number of items written to the
history file, rather than 0-on-success as our code is expecting.
So we print out a bogus error report mentioning the prior value of errno.

I'm not sure if this behavior is common to all versions of libedit,
but consulting Apple's source at
http://www.opensource.apple.com/darwinsource/10.3/libedit-3/libedit/history.c
makes it clear (look at history_save() about 3/4ths of the way down).
The function actually fails to detect I/O errors at all, other than
failure of the initial open() call.

What I'm kind of inclined to do is change our saveHistory() function
to not look at the return value of write_history() at all, but instead
do
errno = 0;write_history(fname);  /* return value is not standardized */if (errno)    print message;

Anyone have a better idea?
        regards, tom lane


Re: Segfault Exiting psql

От
Jason Essington
Дата:
Has there been any movement on this? as of 8.1.2 psql still whines on  
OS X tiger when you exit.
I realize it is not significant, but I'd still rather not see it.
In the interim, I've done:
    errno = 0;    write_history(fname);  /* return value is not standardized */    if (errno)        psql_error("could
notsave history to file \"%s\": %s\n", fname,  
 
strerror(errno));    else        return true;

and it seems to have cured the problem for me. Is this even  
reasonable? I'm not a C programmer

-jason

On Aug 28, 2005, at 12:04 PM, Tom Lane wrote:

> What I'm kind of inclined to do is change our saveHistory() function
> to not look at the return value of write_history() at all, but instead
> do
>
>     errno = 0;
>     write_history(fname);  /* return value is not standardized */
>     if (errno)
>         print message;
>
> Anyone have a better idea?



Re: Segfault Exiting psql

От
Jeff Trout
Дата:
On Jan 27, 2006, at 10:21 AM, Jason Essington wrote:

> Has there been any movement on this? as of 8.1.2 psql still whines  
> on OS X tiger when you exit.
> I realize it is not significant, but I'd still rather not see it.
> In the interim, I've done:
>
>         errno = 0;
>         write_history(fname);  /* return value is not standardized */
>         if (errno)
>             psql_error("could not save history to file \"%s\": %s\n", fname,  
> strerror(errno));
>         else
>             return true;


I can into this recently on my osx install.
It is another case of Apple being really, really stupid.

Look to see if /usr/lib/libreadline.dylib is a symlink to libedit
Once I made libreadline actually readline, it stopped segfaulting.  
(Highly annoying since I kept trying to recompile to get it to work).
You can also use otool -L psql to check to see what it is actually  
linking as well.

(You were getting those core dumps and the message about szone_error  
right - I missed the rest of the thread)

--
Jeff Trout <jeff@jefftrout.com>
http://www.jefftrout.com/
http://www.stuarthamm.net/




Re: Segfault Exiting psql

От
Tom Lane
Дата:
Jason Essington <jasone@GreenRiverComputing.com> writes:
> Has there been any movement on this? as of 8.1.2 psql still whines on  
> OS X tiger when you exit.
> I realize it is not significant, but I'd still rather not see it.

I've committed that fix into CVS HEAD.
        regards, tom lane