Обсуждение: Bus Error in psql command history

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

Bus Error in psql command history

От
Isaac Morland
Дата:
I run psql on Mac OS X:

psql (8.4.1, server 8.4.0)

Then paste the following in, having been copied from an XCode editor
window:

CREATE OR REPLACE FUNCTION compute_mw_realname (
     nicknames text,
     givennames text,
     surname text
) RETURNS text AS $$
     DECLARE
         first text;
         last text;
     BEGIN
         last := replace (trim (surname), '-', '');
         IF nicknames IS NOT NULL THEN
             first := replace (trim (nicknames), '-', '');
             IF substring (first from 1 + length (first) - length (last))
              = last THEN
                 first := trim (substring
                  (first from 1 for length (first) - length (last)));
                 IF first = '' THEN
                     first = replace (trim (givennames), '-', '');
                 END IF;
             END IF;
         ELSE
             first := replace (trim (givennames), '-', '');
         END IF;
         first = replace (first, '-', '');
         RETURN upper (substring (first from 1 for 1)) ||
          substring (first from 2) || ' ' || last;
     END;
$$ LANGUAGE PLPGSQL IMMUTABLE;

After this executes, which it does successfully, if I use cursor-up to
re-display this command, I get an immediate bus error and psql quits.

If I don't use cursor-up, I can continue typing commands, but if I later
cursor-up far enough that the above command should be re-displayed then I
get the bus error at that time.

Works fine on psql 8.4.1 for Solaris.

Please advise if you would like any more details about the behaviour.  I
can think of a few things to investigate but none that jumps out as the
obvious thing to look into.

Isaac Morland            CSCF Web Guru
DC 2554C, x36650        WWW Software Specialist

Re: Bus Error in psql command history

От
Alvaro Herrera
Дата:
Isaac Morland wrote:
> I run psql on Mac OS X:


> Please advise if you would like any more details about the
> behaviour.  I can think of a few things to investigate but none that
> jumps out as the obvious thing to look into.

I think Mac OS X ships a broken libreadline.  What happens if you
compile with a stock one?

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

Re: Bus Error in psql command history

От
Tom Lane
Дата:
Alvaro Herrera <alvherre@commandprompt.com> writes:
> I think Mac OS X ships a broken libreadline.  What happens if you
> compile with a stock one?

FWIW, it's still broken in Snow Leopard :-(.  Stack trace is

(gdb) bt
#0  0x0000000100097ccc in re_putc ()
#1  0x00000001000981f6 in re_refresh ()
#2  0x0000000100097b67 in el_gets ()
#3  0x00000001000a49b6 in readline ()
#4  0x000000010000856f in gets_interactive (prompt=<value temporarily unavailable, due to optimizations>) at input.c:76
#5  0x0000000100008b8b in MainLoop (source=0x7fff701140c0) at mainloop.c:132
#6  0x000000010000b14f in main (argc=<value temporarily unavailable, due to optimizations>, argv=0x7fff5fbff5f0) at
startup.c:285
(gdb)

which pretty conclusively puts the blame on libedit.  This isn't the
first libedit bug report we've seen, either.

            regards, tom lane