Hi,

On Wed, Aug 29, 2012 at 06:47:24AM +0530, Raghavendra D Prabhu wrote:
>  532     partial_key:
>  533             /*
>  534              * Escape but no key string. If have already seen an escape 
> and the
>  535              * timer has expired, give up waiting and send the escape.
>  536              */
>  537             if ((tty->flags & TTY_ESCAPE) &&
>  538                 !evtimer_pending(&tty->key_timer, NULL)) {
>  539                     evbuffer_drain(tty->event->input, 1);
>  540                     key = '\033';
>  541                     goto handle_key;
>  548             if (evtimer_pending(&tty->key_timer, NULL))
> 
> The key_timer is uninitialized at the moment which causes the crash.

It's slightly more complicated than that.  It seems as though we were always
being a bit naughty in using events here -- your trace shows a chunk of
memory which isn't an event at all.

I think we should be calling evtimer_pending() only when the event has been
initialised prior to checking it.  See the patch below.  This should fix
your problem.

Nicholas -- I've tested this with the version of libevent reported here
(2.0.20) as well as 2.0.19, and this shows no problems.  I do not know about
the 1.4.X stable releases though.

Kindly,

-- Thomas Adam
diff --git a/trunk/tty-keys.c b/trunk/tty-keys.c
index 5caf516..fe0e084 100644
--- a/trunk/tty-keys.c
+++ b/trunk/tty-keys.c
@@ -27,6 +27,9 @@
 
 #include "tmux.h"
 
+#define EV_TIMER_PENDING(t) (evtimer_initialized(t) && \
+		evtimer_pending(t, NULL))
+
 /*
  * Handle keys input from the outside terminal. tty_keys[] is a base table of
  * supported keys which are looked up in terminfo(5) and translated into a
@@ -533,7 +536,7 @@ partial_key:
 	 * timer has expired, give up waiting and send the escape.
 	 */
 	if ((tty->flags & TTY_ESCAPE) &&
-	    !evtimer_pending(&tty->key_timer, NULL)) {
+	    !EV_TIMER_PENDING(&tty->key_timer)) {
 		evbuffer_drain(tty->event->input, 1);
 		key = '\033';
 		goto handle_key;
@@ -543,7 +546,7 @@ partial_key:
 
 start_timer:
 	/* If already waiting for timer, do nothing. */
-	if (evtimer_pending(&tty->key_timer, NULL))
+	if (EV_TIMER_PENDING(&tty->key_timer))
 		return (0);
 
 	/* Start the timer and wait for expiry or more data. */
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to