NetBSD Problem Report #39209

From cliff@snipe444.org  Fri Jul 25 17:55:15 2008
Return-Path: <cliff@snipe444.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 2A16A63B91E
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 25 Jul 2008 17:55:15 +0000 (UTC)
Message-Id: <20080725175501.D31151C710@blitzen.snipe444.org>
Date: Fri, 25 Jul 2008 10:55:01 -0700 (PDT)
From: cliff@snipe444.org
Reply-To: cliff@snipe444.org
To: gnats-bugs@gnats.NetBSD.org
Subject: XGrabKeyboard time problem seen with openmotif menu
X-Send-Pr-Version: 3.95

>Number:         39209
>Category:       xsrc
>Synopsis:       XGrabKeyboard time problem seen with openmotif menu
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    mrg
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 25 18:00:00 +0000 2008
>Closed-Date:    Fri Jun 04 16:05:52 +0000 2010
>Last-Modified:  Fri Jun 04 16:05:52 +0000 2010
>Originator:     Cliff Wright
>Release:        NetBSD 4.0
>Organization:

>Environment:


System: NetBSD blitzen-qemu 4.0 NetBSD 4.0 (GENERIC) #2: Wed Jul 23 10:19:59 PDT 2008 cliff@blitzen-qemu/usr/src/sys/arch/sparc/compile/GENERIC sparc
Architecture: sparc
Machine: sparc
>Description:
	A program using openmotif could not pop up a menu. I tracked
	this down to a call of XtGrabKeyboard returning GrabInvalidTime.
	This occurs because the version of GetTimeInMillis that NetBSD
	uses was modified to return a delta time instead of absolute
	time, which is incompatible with devices that return absolute
	time. This change to delta was made in an attempt to guarantee
	an always increasing time. However their are 8 different places
	where this function is implemented, and only the one had the
	change. Also it is not clear if this is an Xfree86 change, or
	a NetBSD change. I don't see the file in Xfree86 CVS(including
	attic), but it does show in a changelog.
	  Reverting to the absolute time version fixed the problem for me.
>How-To-Repeat:

>Fix:
	Revert xsrc/xfree/xc/programs/Xserver/os/GetTimeInMillis to
	CVS version 1.4

>Release-Note:

>Audit-Trail:
From: Cliff Wright <cliff@snipe444.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: xsrc/39209: XGrabKeyboard time problem seen with openmotif menu
Date: Mon, 28 Jul 2008 09:39:24 -0700

 This is a multi-part message in MIME format.

 --Multipart=_Mon__28_Jul_2008_09_39_24_-0700_F3EDm/VfJgP.mLz6
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit

 Looking at the code I see that an increasing time can be returned as an
 absolute(actually semi, as an overflow will occur after multipling seconds
 by 1000 to make into milliseconds) time with the followig patch.
 -- 
 Cliff Wright <cliff@snipe444.org>

 --Multipart=_Mon__28_Jul_2008_09_39_24_-0700_F3EDm/VfJgP.mLz6
 Content-Type: text/plain;
  name="xpatch.txt"
 Content-Disposition: attachment;
  filename="xpatch.txt"
 Content-Transfer-Encoding: 7bit

 --- Xserver/os/GetTimeInMillis.c.distrib	2005-03-18 06:55:16.000000000 -0800
 +++ Xserver/os/GetTimeInMillis.c	2008-07-28 09:11:36.000000000 -0700
 @@ -6,18 +6,15 @@
  {
      struct timeval  tp;
      register CARD32 val;
 -    register INT32 diff;
      static CARD32 oldval = 0;
 -    static CARD32 time = 0;

      X_GETTIMEOFDAY(&tp);
      val = (tp.tv_sec * 1000) + (tp.tv_usec / 1000);
 -    if (oldval) {
 -	diff = val - oldval;
 -	if (diff > 0)
 -	    time += diff;
 -    }
 -    oldval = val;
 +    /* make sure time always increases */
 +    if (val - oldval < 0)
 +	val = oldval;
 +    else
 +	oldval = val;

 -    return time;
 +    return val;
  }

 --Multipart=_Mon__28_Jul_2008_09_39_24_-0700_F3EDm/VfJgP.mLz6--

Responsible-Changed-From-To: xsrc-manager->mrg
Responsible-Changed-By: mrg@NetBSD.org
Responsible-Changed-When: Tue, 01 Jun 2010 08:02:02 +0000
Responsible-Changed-Why:
i'll take care of this.


State-Changed-From-To: open->analyzed
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Tue, 01 Jun 2010 08:02:02 +0000
State-Changed-Why:
cliff provided all the right details; i'm just going to revert the xfree tree
to use 4.4 version of this, instead of the 4.5 version.

the reason it was hard to see is that we have moved this function into its
own file.

the xorg-server never picked up this change, and thus this has actually
been fixed for many platforms since netbsd 5.


State-Changed-From-To: analyzed->feedback
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Fri, 04 Jun 2010 02:26:14 +0000
State-Changed-Why:
ok, i've commited this to xsrc.

cliff, would you like this pulled up to any branch?  (netbsd-4, netbsd-5)

thanks!


From: matthew green <mrg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39209 CVS commit: xsrc/xfree/xc/programs/Xserver/os
Date: Fri, 4 Jun 2010 02:24:45 +0000

 Module Name:	xsrc
 Committed By:	mrg
 Date:		Fri Jun  4 02:24:45 UTC 2010

 Modified Files:
 	xsrc/xfree/xc/programs/Xserver/os: GetTimeInMillis.c

 Log Message:
 backout the xfree86 4.5 change to GetTimeInMillis() that returns
 relative times instead of absolute times.  it causes problems in
 openmotif at the very least, and is not what xorg has done.

 from Cliff Wright in PR#39209.


 To generate a diff of this commit:
 cvs rdiff -u -r1.5 -r1.6 xsrc/xfree/xc/programs/Xserver/os/GetTimeInMillis.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Cliff Wright <cliff@snipe444.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: xsrc/39209 (XGrabKeyboard time problem seen with openmotif
 menu)
Date: Thu, 3 Jun 2010 23:39:49 -0700

 On Fri,  4 Jun 2010 02:26:15 +0000 (UTC)
 mrg@NetBSD.org wrote:

 > cliff, would you like this pulled up to any branch?  (netbsd-4, netbsd-5)
 Thanks, for myself with recent upgrades, and starting to use Xorg
 I am good.

 -- 
 Cliff Wright <cliff@snipe444.org>

State-Changed-From-To: feedback->closed
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Fri, 04 Jun 2010 16:05:52 +0000
State-Changed-Why:
all done, thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.