From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Eric M. Ludlam" Newsgroups: gmane.emacs.bugs Subject: bug#15045: Point jumps inappropriately around time of Semantic lexing Date: Thu, 08 Aug 2013 23:26:37 -0400 Message-ID: <5204616D.4020702@siege-engine.com> References: <87pptptk9n.fsf@engster.org> <87eha4t7xz.fsf@engster.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1376018843 26562 80.91.229.3 (9 Aug 2013 03:27:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 Aug 2013 03:27:23 +0000 (UTC) Cc: Barry OReilly , 15045@debbugs.gnu.org To: David Engster Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 09 05:27:22 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V7dMG-0000gS-15 for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Aug 2013 05:27:20 +0200 Original-Received: from localhost ([::1]:57101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7dMF-0007nq-FJ for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Aug 2013 23:27:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7dM6-0007mn-GZ for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2013 23:27:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V7dLz-0002fp-66 for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2013 23:27:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7dLz-0002fg-1s for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2013 23:27:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1V7dLy-0006z9-JB for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2013 23:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Eric M. Ludlam" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Aug 2013 03:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15045 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15045-submit@debbugs.gnu.org id=B15045.137601881026831 (code B ref 15045); Fri, 09 Aug 2013 03:27:02 +0000 Original-Received: (at 15045) by debbugs.gnu.org; 9 Aug 2013 03:26:50 +0000 Original-Received: from localhost ([127.0.0.1]:48452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V7dLl-0006yh-Ta for submit@debbugs.gnu.org; Thu, 08 Aug 2013 23:26:50 -0400 Original-Received: from mail-vb0-f49.google.com ([209.85.212.49]:50247) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V7dLi-0006yR-1G for 15045@debbugs.gnu.org; Thu, 08 Aug 2013 23:26:46 -0400 Original-Received: by mail-vb0-f49.google.com with SMTP id w16so3775540vbb.36 for <15045@debbugs.gnu.org>; Thu, 08 Aug 2013 20:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=I/E5M75B1qJAvz5aw9NeWTQeBnLyOWZAxEEDPoy9xxs=; b=a/bx532C296Fskmh04lRHeFFX3bkVh6Og73YPYX+/t6wYNp/D6nbnrTat8dkb69S1N MKvqwq9gGFQ7uJphCqeHoVqxRQHQqyRzj6Es/ctqLvGF02sp4Lo50Ck0CqRlYXTyNzSs fKNMKNO61h408fvAzvQDn5uTdNK6g/XGPn3Zpx0YZIPnwBCLuVuVTzb8DT4wcoE0ngbc Vd3aS+P+wQVv2sa5S5pSDx52g0ywHLHZBShC9/K/RdBEEZa794+vCk7SH/JGa6aNDm2w KfOoMbAfZ4urYPiD5cSFQZL+6J41sRDg1ueYL8B+MUloDLcJYiK9dSineygDoJnMzVCP Svww== X-Received: by 10.58.19.136 with SMTP id f8mr3111777vee.98.1376018800281; Thu, 08 Aug 2013 20:26:40 -0700 (PDT) Original-Received: from [192.168.1.201] (pool-72-74-140-235.bstnma.fios.verizon.net. [72.74.140.235]) by mx.google.com with ESMTPSA id p10sm9550271vdi.7.2013.08.08.20.26.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 20:26:39 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.3a1pre) Gecko/20091222 Shredder/3.1a1pre In-Reply-To: <87eha4t7xz.fsf@engster.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:77121 Archived-At: On 08/08/2013 01:21 PM, David Engster wrote: > [Adding Eric to CC] > > David Engster writes: > > It's kinda hard to trigger this problem through jit-lock, since its idle > time is much smaller than the one from Semantic. So I disabled it and > tried to trigger the jump by stopping typing at roughly XX:XX:59. The > semantic idle function kicks in after 1 second, and lo and behold, I saw > a jump. It's still difficult to reproduce, but I managed to get two > backtraces in the past hour, which are attached. > > As you can see, the display-time-event-handler does indeed interrupt the > lexing phase. It does a `sit-for', the display jumps. Not sure what > happens after that. Does the semantic-idle function resume? Anyway, > somehow point gets back to its original position, and through > `trace-redisplay', I saw the following on stderr: David, this is some impressing debugging. Thanks for investigating so thoroughly. > You might wonder how the display-time-event-handler can interrupt the > Semantic lexer. In the two backtraces, you see that it calls > `accept-process-output' and `input-pending-p'. This is hidden inside the > macro `semantic-throw-on-input', which can be called in code wrapped > inside `semantic-exit-on-input'; it's our poor-man's 'yield'. It's used > extensively in the idle function code, and it's just there to do a > non-local exit in case the user does something. However, now I know that > it also allows other timers to run. > > If you look in the `define-lex' macro, you see that it calls > `semantic-throw-on-input' after each identified token. The problem is > that it does not restore the cursor position before that, so I guess the > fix is simply to change this call to > > (save-excursion > (goto-char starting-position) > (semantic-throw-on-input 'lex)) I pulled up some of the bigger C files in Emacs, ran the lexer, and they all took less than .3 second to lex. It may also be safe to remove this interactive optimization and just depend on input checking that happens during parsing. The detriment is that if someone had a really big file, they might notice that Emacs stops responding if lexing takes a long time. Eric