Subject: Re: bug#16737: Timed out waiting for reply from selection owner

From: Eli Zaretskii <[email-masked]>
Date: Mon, 19 Jan 2015 19:46:02 +0200

> From: Vincent Bernat <[email-masked]>
> Cc: Oleh Krehel <[email-masked]>,  [email-masked]
> Date: Sat, 17 Jan 2015 22:43:21 +0100
> 
>  ❦ 17 janvier 2015 20:07 +0200, Eli Zaretskii <[email-masked]> :
> 
> >> The thing is, I don't know how to get a backtrace - I'm only a novice
> >> with GDB.  I was hoping someone would post a sequence of commands to
> >> get a proper backtrace for this problem.
> >
> > During those 5 seconds, attach GDB to the Emacs process:
> >
> >   $ gdb -p PID
> >
> > where PID is the numeric process ID of Emacs; you can find that out
> > in advance, before you start the reproducing sequence, and prepare the
> > above command line, so that all you need to do is hit RET.
> >
> > Then, when GDB displays its prompt "(gdb)", type this:
> >
> >   thread apply all bt
> >
> > This will show a backtrace of every thread in the Emacs process.
> 
> I also have the same problem. It happens randomly when I try to paste or
> when I try to kill something. Once it happens, it happens often. I
> usually restart emacs after cursing it a lot. The backtrace is always
> the same:
> 
> #0  0x00007fdbf286d009 in __pselect (nfds=nfds@entry=27,
>  readfds=readfds@entry=0x7fff9569f510, writefds=writefds@entry=0x0,
>  exceptfds=exceptfds@entry=0x0, timeout=<optimized out>,
>  timeout@entry=0x7fff9569faf0, sigmask=sigmask@entry=0x0) at
>  ../sysdeps/unix/sysv/linux/pselect.c:77
> #1  0x00000000005d4ac2 in xg_select (fds_lim=27,
>  rfds=rfds@entry=0x7fff9569fb10, wfds=wfds@entry=0x0,
>  efds=efds@entry=0x0, timeout=timeout@entry=0x7fff9569faf0,
>  sigmask=sigmask@entry=0x0) at xgselect.c:105
> #2  0x0000000000599b66 in wait_reading_process_output
>  (time_limit=<optimized out>, nsecs=0, read_kbd=0, do_display=false,
>  wait_for_cell=12579542, wait_proc=0x0, just_wait_proc=0) at
>  process.c:4606
> #3  0x00000000004d2239 in x_get_foreign_selection (selection_symbol=27,
>  target_type=12623842, time_stamp=12315698, frame=-1) at xselect.c:1237

This just shows that Emacs is waiting for the SelectionNotify event.

Can you compile xselect.c while enabling the TRACEs there, and show
the output you get?

Also, if your value of x-selection-timeout is not zero, does it help
to enlarge it?