Re: Segfault Exiting psql

Lists: pgsql-hackers
From: David Wheeler <david(at)justatheory(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Segfault Exiting psql
Date: 2005-07-14 23:24:37
Message-ID: 3B715BA0-CC81-4B3C-9174-5357129AABB7@justatheory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Wheeler <david(at)justatheory(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Segfault Exiting psql
Date: 2005-07-15 23:55:14
Message-ID: 21684.1121471714@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

David Wheeler <david(at)justatheory(dot)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


From: David Wheeler <david(at)justatheory(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Segfault Exiting psql
Date: 2005-07-16 00:13:19
Message-ID: 5148828E-586A-4355-A66F-9946AD9E8668@justatheory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: David Wheeler <david(at)kineticode(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Segfault Exiting psql
Date: 2005-07-26 19:44:21
Message-ID: 93AED4E3-678F-4AD8-8182-6254B85C0C7B@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Wheeler <david(at)justatheory(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: Segfault Exiting psql
Date: 2005-08-28 18:04:43
Message-ID: 25600.1125252283@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: Jason Essington <jasone(at)GreenRiverComputing(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Segfault Exiting psql
Date: 2006-01-27 15:21:23
Message-ID: EC943F3C-D236-458A-B5ED-FE8F81990B81@GreenRiverComputing.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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;

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?


From: Jeff Trout <threshar(at)torgo(dot)978(dot)org>
To: Jason Essington <jasone(at)GreenRiverComputing(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Segfault Exiting psql
Date: 2006-01-27 19:06:05
Message-ID: 890B76D3-CE89-48A8-A466-4409FBB7D054@torgo.978.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


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(at)jefftrout(dot)com>
http://www.jefftrout.com/
http://www.stuarthamm.net/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jason Essington <jasone(at)GreenRiverComputing(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Segfault Exiting psql
Date: 2006-06-18 17:35:12
Message-ID: 11136.1150652112@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jason Essington <jasone(at)GreenRiverComputing(dot)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