Thread: Function keys cause psql to segfault

Function keys cause psql to segfault

From
CSN
Date:
If I'm in psql (via putty, from WinXP to Redhat) and
hit F1-4 (F5+ just display a ~), psql will
segmentation fault and exit. Not that I'm in the habit
of entering function keys while in psql - I
accidentally hit one while entering numbers (lost a
fair amount of history).

I just tried it using WinXP's command prompt and none
of the function keys cause psql to segfault.

CSN

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: Function keys cause psql to segfault

From
Bruce Momjian
Date:
CSN wrote:
> If I'm in psql (via putty, from WinXP to Redhat) and
> hit F1-4 (F5+ just display a ~), psql will
> segmentation fault and exit. Not that I'm in the habit
> of entering function keys while in psql - I
> accidentally hit one while entering numbers (lost a
> fair amount of history).

My guess is that those send a break or some control sequence.  od -c
might show you what is being output.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Function keys cause psql to segfault

From
CSN
Date:
Here's what 'od -c' shows for F1-4:

^[OP^[OQ^[OR^[OS


CSN

--- Bruce Momjian <pgman@candle.pha.pa.us> wrote:

> CSN wrote:
> > If I'm in psql (via putty, from WinXP to Redhat)
> and
> > hit F1-4 (F5+ just display a ~), psql will
> > segmentation fault and exit. Not that I'm in the
> habit
> > of entering function keys while in psql - I
> > accidentally hit one while entering numbers (lost
> a
> > fair amount of history).
>
> My guess is that those send a break or some control
> sequence.  od -c
> might show you what is being output.
>
> --
>   Bruce Momjian                        |
> http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610)
> 359-1001
>   +  If your life is a hard drive,     |  13 Roberts
> Road
>   +  Christ can be your backup.        |  Newtown
> Square, Pennsylvania 19073
>




__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

Re: Function keys cause psql to segfault

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> CSN wrote:
>> If I'm in psql (via putty, from WinXP to Redhat) and
>> hit F1-4 (F5+ just display a ~), psql will
>> segmentation fault and exit.

> My guess is that those send a break or some control sequence.  od -c
> might show you what is being output.

Try watching the psql process with strace in another terminal window.
If Bruce's theory is correct (and it sounds good to me) then you should
be able to see a signal being delivered to psql.

            regards, tom lane

Re: Function keys cause psql to segfault

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > CSN wrote:
> >> If I'm in psql (via putty, from WinXP to Redhat) and
> >> hit F1-4 (F5+ just display a ~), psql will
> >> segmentation fault and exit.
>
> > My guess is that those send a break or some control sequence.  od -c
> > might show you what is being output.
>
> Try watching the psql process with strace in another terminal window.
> If Bruce's theory is correct (and it sounds good to me) then you should
> be able to see a signal being delivered to psql.

Also, try the function keys in another command-line application and see
if that exits too.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Function keys cause psql to segfault

From
CSN
Date:
I did 'strace psql dbname' and this was the output
after hitting F1:

read(0, "\33", 1)                       = 1
read(0, "O", 1)                         = 1
read(0, "P", 1)                         = 1
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++


CSN

--- Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > CSN wrote:
> >> If I'm in psql (via putty, from WinXP to Redhat)
> and
> >> hit F1-4 (F5+ just display a ~), psql will
> >> segmentation fault and exit.
>
> > My guess is that those send a break or some
> control sequence.  od -c
> > might show you what is being output.
>
> Try watching the psql process with strace in another
> terminal window.
> If Bruce's theory is correct (and it sounds good to
> me) then you should
> be able to see a signal being delivered to psql.
>
>             regards, tom lane
>




__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

Re: Function keys cause psql to segfault

From
CSN
Date:
Hmm, all I could think of was perl and php - hitting
F1-4 just caused these chars to be displayed (the
interpreters didn't exit):

^[OP^[OQ^[OR^[OS


CSN

--- Bruce Momjian <pgman@candle.pha.pa.us> wrote:

> Tom Lane wrote:
> > Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > > CSN wrote:
> > >> If I'm in psql (via putty, from WinXP to
> Redhat) and
> > >> hit F1-4 (F5+ just display a ~), psql will
> > >> segmentation fault and exit.
> >
> > > My guess is that those send a break or some
> control sequence.  od -c
> > > might show you what is being output.
> >
> > Try watching the psql process with strace in
> another terminal window.
> > If Bruce's theory is correct (and it sounds good
> to me) then you should
> > be able to see a signal being delivered to psql.
>
> Also, try the function keys in another command-line
> application and see
> if that exits too.
>
> --
>   Bruce Momjian                        |
> http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610)
> 359-1001
>   +  If your life is a hard drive,     |  13 Roberts
> Road
>   +  Christ can be your backup.        |  Newtown
> Square, Pennsylvania 19073
>




__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

Re: Function keys cause psql to segfault

From
Tom Lane
Date:
CSN <cool_screen_name90001@yahoo.com> writes:
> I did 'strace psql dbname' and this was the output
> after hitting F1:

> read(0, "\33", 1)                       = 1
> read(0, "O", 1)                         = 1
> read(0, "P", 1)                         = 1
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---

Hmm ... I don't have an F1 key, but I typed escape-O-P at a psql
running under Linux, and got this:

Process 28978 attached - interrupt to quit
read(0, "\33", 1)                       = 1
read(0, "O", 1)                         = 1
read(0, "P", 1)                         = 1
write(2, "\7", 1)                       = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
read(0,

So it seems fine here.  I'm wondering if there's something broken
about your machine's readline library.

            regards, tom lane

Re: Function keys cause psql to segfault

From
Klint Gore
Date:
On Sun, 25 Sep 2005 20:00:03 -0700 (PDT), CSN <cool_screen_name90001@yahoo.com> wrote:
>
> I did 'strace psql dbname' and this was the output
> after hitting F1:
>
> read(0, "\33", 1)                       = 1
> read(0, "O", 1)                         = 1
> read(0, "P", 1)                         = 1
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV +++

esc O P is PF1 on a VT100/VT200.  Does it make any difference if you
change the terminal emulation in putty or the term setting in redhat?

klint.

+---------------------------------------+-----------------+
: Klint Gore                            : "Non rhyming    :
: EMail   : kg@kgb.une.edu.au           :  slang - the    :
: Snail   : A.B.R.I.                    :  possibilities  :
: Mail      University of New England   :  are useless"   :
:           Armidale NSW 2351 Australia :     L.J.J.      :
: Fax     : +61 2 6772 5376             :                 :
+---------------------------------------+-----------------+

Re: Function keys cause psql to segfault

From
CSN
Date:
It looks like I had readline 4.3 installed. I just
installed readline 5.0 - the F1-4 keys still cause
psql to segfault. (AFAIK I don't need to recompile
postgres for psql to use the newly installed
readline).

CSN

--- Tom Lane <tgl@sss.pgh.pa.us> wrote:

> CSN <cool_screen_name90001@yahoo.com> writes:
> > I did 'strace psql dbname' and this was the output
> > after hitting F1:
>
> > read(0, "\33", 1)                       = 1
> > read(0, "O", 1)                         = 1
> > read(0, "P", 1)                         = 1
> > --- SIGSEGV (Segmentation fault) @ 0 (0) ---
>
> Hmm ... I don't have an F1 key, but I typed
> escape-O-P at a psql
> running under Linux, and got this:
>
> Process 28978 attached - interrupt to quit
> read(0, "\33", 1)                       = 1
> read(0, "O", 1)                         = 1
> read(0, "P", 1)                         = 1
> write(2, "\7", 1)                       = 1
> rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
> read(0,
>
> So it seems fine here.  I'm wondering if there's
> something broken
> about your machine's readline library.
>
>             regards, tom lane
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: Function keys cause psql to segfault

From
CSN
Date:
Hmm, in putty (Terminal->Keyboard) I changed "the
function keys and keypad" from "ESC[n~" to "Linux".
Hitting F1-5 in psql outputs "ABCDE" - no segfaults!
Setting it to "Xterm R6" also results in function keys
1-4 causing segfaults (there are also options for
"VT400", "VT100+", and "SCO" - haven't tried those).

Thanks,
CSN

--- Klint Gore <kg@kgb.une.edu.au> wrote:

> On Sun, 25 Sep 2005 20:00:03 -0700 (PDT), CSN
> <cool_screen_name90001@yahoo.com> wrote:
> >
> > I did 'strace psql dbname' and this was the output
> > after hitting F1:
> >
> > read(0, "\33", 1)                       = 1
> > read(0, "O", 1)                         = 1
> > read(0, "P", 1)                         = 1
> > --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> > +++ killed by SIGSEGV +++
>
> esc O P is PF1 on a VT100/VT200.  Does it make any
> difference if you
> change the terminal emulation in putty or the term
> setting in redhat?
>
> klint.
>
>
+---------------------------------------+-----------------+
> : Klint Gore                            : "Non
> rhyming    :
> : EMail   : kg@kgb.une.edu.au           :  slang -
> the    :
> : Snail   : A.B.R.I.                    :
> possibilities  :
> : Mail      University of New England   :  are
> useless"   :
> :           Armidale NSW 2351 Australia :     L.J.J.
>      :
> : Fax     : +61 2 6772 5376             :
>      :
>
+---------------------------------------+-----------------+
>




__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

Re: Function keys cause psql to segfault

From
Douglas McNaught
Date:
CSN <cool_screen_name90001@yahoo.com> writes:

> Hmm, in putty (Terminal->Keyboard) I changed "the
> function keys and keypad" from "ESC[n~" to "Linux".
> Hitting F1-5 in psql outputs "ABCDE" - no segfaults!
> Setting it to "Xterm R6" also results in function keys
> 1-4 causing segfaults (there are also options for
> "VT400", "VT100+", and "SCO" - haven't tried those).

Sounds like it might be useful to compile psql with debugging symbols
and get a backtrace from the crash.

-Doug

Re: Function keys cause psql to segfault

From
Chris Travers
Date:
Douglas McNaught wrote:

>CSN <cool_screen_name90001@yahoo.com> writes:
>
>
>
>>Hmm, in putty (Terminal->Keyboard) I changed "the
>>function keys and keypad" from "ESC[n~" to "Linux".
>>Hitting F1-5 in psql outputs "ABCDE" - no segfaults!
>>Setting it to "Xterm R6" also results in function keys
>>1-4 causing segfaults (there are also options for
>>"VT400", "VT100+", and "SCO" - haven't tried those).
>>
>>
>
>Sounds like it might be useful to compile psql with debugging symbols
>and get a backtrace from the crash.
>
>
Just an oddball theory:

Do we really know what data is being sent with the function keys from
XP?  If Putty is doing passthrough encoding, this might be the problem.

The od output doesn't look right to me.  One should try:
od -c
F1F2F3F4 ctrl-D
When I try this on a gterm, I get:
^[OQ^[OR^[OS0000000 033   O   Q 033   O   R 033   O   S
0000011
My guess is that Windows is sending some data (maybe embedded nulls) in
the data from the Fn key sequences that is causing Readline to crash.

In that case it would be a readline bug not something correctable in
psql I'm afraid.

Best Wishes,
Chris Travers
Metatron Technology Consultingp

>-Doug
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>
>
>
>