all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* flymake mode freezes emacs
@ 2007-08-06  7:42 Ralf Schmitt
  2007-08-07  1:22 ` Richard Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Ralf Schmitt @ 2007-08-06  7:42 UTC (permalink / raw)
  To: emacs-devel

when using flymake with pyflakes
(http://divmod.org/projects/pyflakes)emacs hangs for around 10 seconds 
with certain input files. If I load the attached python file and turn on 
flymake mode, emacs freezes. If I change pyflakes to only output "could 
not compile 'wiki.py':24: it works.
I tested it with the emacs multi tty branch and emacs 22.1. Both do not 
work.

-----------------------
.emacs:

(when (load "flymake" t)
       (defun flymake-pyflakes-init ()
         (let* ((temp-file (flymake-init-create-temp-buffer-copy
                            'flymake-create-temp-inplace))
            (local-file (file-relative-name
                         temp-file
                         (file-name-directory buffer-file-name))))
           (list "pyflakes" (list local-file))))

       (add-to-list 'flymake-allowed-file-name-masks
                '("\\.py\\'" flymake-pyflakes-init)))


-----
python file:

#! /usr/bin/env python

import os
from ConfigParser import ConfigParser

def wiki_cdb(path=None):
     """
     from mwlib import cdbwiki
     db=cdbwiki.WikiDB(path)
     return db

def image_download(url=None, localpath=None):
     assert url and localpath, "must supply url and localpath for in 
[images] section"
     from mwlib import netdb
     imgdb = netdb.ImageDB(url, localpath)
     return imgdb



dispatch = dict(
     images = dict(download = image_download),
     wiki = dict(cdb = wiki_cdb)
)
------------

Output of pyflakes for this file:
could not compile 'wiki.py':24:
     """
     from mwlib import cdbwiki
     db=cdbwiki.WikiDB(path)
     return db

def image_download(url=None, localpath=None):
     assert url and localpath, "must supply url and localpath for in 
[images] section"
     from mwlib import netdb
     imgdb = netdb.ImageDB(url, localpath)
     return imgdb



dispatch = dict(
     images = dict(download = image_download),
     wiki = dict(cdb = wiki_cdb)
)

 
 
 
 
 
                                              ^

-----------------------

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: flymake mode freezes emacs
  2007-08-06  7:42 flymake mode freezes emacs Ralf Schmitt
@ 2007-08-07  1:22 ` Richard Stallman
  2007-08-07  7:05   ` Ralf Schmitt
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2007-08-07  1:22 UTC (permalink / raw)
  To: Ralf Schmitt; +Cc: emacs-devel

    with certain input files. If I load the attached python file and turn on 
    flymake mode, emacs freezes.

Can you try debugging what is happening?
See etc/DEBUG for advice.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: flymake mode freezes emacs
  2007-08-07  1:22 ` Richard Stallman
@ 2007-08-07  7:05   ` Ralf Schmitt
  2007-08-07 20:11     ` Richard Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Ralf Schmitt @ 2007-08-07  7:05 UTC (permalink / raw)
  To: emacs-devel; +Cc: emacs-devel

Richard Stallman wrote:
>     with certain input files. If I load the attached python file and turn on 
>     flymake mode, emacs freezes.
> 
> Can you try debugging what is happening?
> See etc/DEBUG for advice.

It's trying to repeatedly match some regular expressions. (The 
re_match_2_internal function is called again and again, I added some 
print statements...).
Here is some stacktrace. I guess this is easier to debug directly from 
the lisp code, but I can't help with that..

(gdb) r ~/wiki.py
Starting program: /home/ralf/w/emacs-multi-tty/src/emacs ~/wiki.py
[Thread debugging using libthread_db enabled]
[New Thread 47918546614928 (LWP 29474)]

Program received signal SIGTSTP, Stopped (user).
[Switching to Thread 47918546614928 (LWP 29474)]
0x00000000004fbda2 in re_match_2_internal (bufp=0x9e5258, string1=0x0, 
size1=0,
     string2=0x14c6050 ' ' <repeats 200 times>..., size2=401, pos=10, 
regs=0x9d77c0, stop=401)
     at regex.c:5465
5465                    if (c < (unsigned) (CHARSET_BITMAP_SIZE (&p[-1]) 
* BYTEWIDTH)
(gdb) bt
#0  0x00000000004fbda2 in re_match_2_internal (bufp=0x9e5258, 
string1=0x0, size1=0,
     string2=0x14c6050 ' ' <repeats 200 times>..., size2=401, pos=10, 
regs=0x9d77c0, stop=401)
     at regex.c:5465
#1  0x00000000004fd5ca in re_search_2 (bufp=0x9e5258, str1=0x0, size1=0,
     str2=0x14c6050 ' ' <repeats 200 times>..., size2=401, startpos=10, 
range=<value optimized out>,
     regs=0x9d77c0, stop=401) at regex.c:4455
#2  0x00000000004fdcd3 in re_search (bufp=0x7fffc5453340, string=0x0, 
size=0, startpos=21726946,
     range=<value optimized out>, regs=<value optimized out>) at 
regex.c:4227
#3  0x00000000004f685d in string_match_1 (regexp=19448755, 
string=22042099, start=<value optimized out>,
     posix=0) at search.c:457
#4  0x000000000051d004 in Ffuncall (nargs=<value optimized out>, 
args=<value optimized out>) at eval.c:3036
#5  0x0000000000548bb2 in Fbyte_code (bytestr=<value optimized out>, 
vector=11474641, maxdepth=145)
     at bytecode.c:679
#6  0x000000000051cad8 in funcall_lambda (fun=21328628, nargs=1, 
arg_vector=0x7fffc54570f8) at eval.c:3217
#7  0x000000000051ce86 in Ffuncall (nargs=<value optimized out>, 
args=<value optimized out>) at eval.c:3087
#8  0x0000000000548bb2 in Fbyte_code (bytestr=<value optimized out>, 
vector=12227409, maxdepth=113)
     at bytecode.c:679
#9  0x000000000051cad8 in funcall_lambda (fun=21012180, nargs=2, 
arg_vector=0x7fffc5457288) at eval.c:3217
#10 0x000000000051ce86 in Ffuncall (nargs=<value optimized out>, 
args=<value optimized out>) at eval.c:3087
#11 0x0000000000548bb2 in Fbyte_code (bytestr=<value optimized out>, 
vector=12227409, maxdepth=12)
     at bytecode.c:679
#12 0x000000000051cad8 in funcall_lambda (fun=21577764, nargs=1, 
arg_vector=0x7fffc5457408) at eval.c:3217
#13 0x000000000051ce86 in Ffuncall (nargs=<value optimized out>, 
args=<value optimized out>) at eval.c:3087
#14 0x0000000000548bb2 in Fbyte_code (bytestr=<value optimized out>, 
vector=11567681, maxdepth=26)
     at bytecode.c:679
#15 0x000000000051cad8 in funcall_lambda (fun=20077524, nargs=2, 
arg_vector=0x7fffc5457598) at eval.c:3217
#16 0x000000000051ce86 in Ffuncall (nargs=<value optimized out>, 
args=<value optimized out>) at eval.c:3087
#17 0x000000000051e7e5 in Fapply (nargs=2, args=0x7fffc5457610) at 
eval.c:2518
#18 0x000000000051e940 in apply1 (fn=21333729, arg=<value optimized 
out>) at eval.c:2779
#19 0x000000000051b695 in internal_condition_case_1 (bfun=0x54b4e0 
<read_process_output_call>,
     arg=19679141, handlers=10569201, hfun=0x54b4a0 
<read_process_output_error_handler>) at eval.c:1538
#20 0x000000000054ad7a in read_process_output (proc=22327956, 
channel=<value optimized out>)
     at process.c:5194
#21 0x000000000054b834 in status_notify (deleting_process=0x0) at 
process.c:6797
#22 0x000000000055073c in wait_reading_process_output (time_limit=0, 
microsecs=0, read_kbd=-1,
     do_display=1, wait_for_cell=10455441, wait_proc=0x0, 
just_wait_proc=0) at process.c:4464
#23 0x00000000004bcc74 in read_char (commandflag=1, nmaps=4, 
maps=0x7fffc5459050,
     prev_event=<value optimized out>, used_mouse_menu=0x7fffc5459170, 
end_time=0x0) at keyboard.c:4150
#24 0x00000000004bf8d2 in read_key_sequence (keybuf=0x7fffc54591e0, 
bufsize=30, prompt=10455441,
     dont_downcase_last=0, can_return_switch_frame=1, 
fix_current_buffer=1) at keyboard.c:9380
#25 0x00000000004c15f0 in command_loop_1 () at keyboard.c:1696
#26 0x000000000051b917 in internal_condition_case (bfun=0x4c1450 
<command_loop_1>, handlers=10569201,
     hfun=0x4bb5e0 <cmd_error>) at eval.c:1488
#27 0x00000000004ba99a in command_loop_2 () at keyboard.c:1405
#28 0x000000000051ba07 in internal_catch (tag=<value optimized out>, 
func=0x4ba980 <command_loop_2>,
     arg=10455441) at eval.c:1223
#29 0x00000000004bb423 in command_loop () at keyboard.c:1384
#30 0x00000000004bb7bc in recursive_edit_1 () at keyboard.c:993
#31 0x00000000004bb921 in Frecursive_edit () at keyboard.c:1055
#32 0x00000000004afcfb in main (argc=2, argv=0x7fffc5459a88) at emacs.c:1772

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: flymake mode freezes emacs
  2007-08-07  7:05   ` Ralf Schmitt
@ 2007-08-07 20:11     ` Richard Stallman
  2007-08-08 10:02       ` Ralf Schmitt
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2007-08-07 20:11 UTC (permalink / raw)
  To: Ralf Schmitt; +Cc: emacs-devel

You can debug the Lisp level with GDB.  We need to know the regexp.
You can find it by examining the first arg of the search or match
function using pr.

    #3  0x00000000004f685d in string_match_1 (regexp=19448755, 
    string=22042099, start=<value optimized out>,
	 posix=0) at search.c:457
    #4  0x000000000051d004 in Ffuncall (nargs=<value optimized out>, 
    args=<value optimized out>) at eval.c:3036

Type

   f 4
   p args[1]
   pr

We also need to know where it is looping.  You can find that
by following the instructions in etc/DEBUG about looping.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: flymake mode freezes emacs
  2007-08-07 20:11     ` Richard Stallman
@ 2007-08-08 10:02       ` Ralf Schmitt
  2007-08-09  0:07         ` Richard Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Ralf Schmitt @ 2007-08-08 10:02 UTC (permalink / raw)
  To: emacs-devel

Richard Stallman wrote:
> You can debug the Lisp level with GDB.  We need to know the regexp.
> You can find it by examining the first arg of the search or match
> function using pr.
> 
>     #3  0x00000000004f685d in string_match_1 (regexp=19448755, 
>     string=22042099, start=<value optimized out>,
> 	 posix=0) at search.c:457
>     #4  0x000000000051d004 in Ffuncall (nargs=<value optimized out>, 
>     args=<value optimized out>) at eval.c:3036
> 
> Type
> 
>    f 4
>    p args[1]
>    pr
> 
> We also need to know where it is looping.  You can find that
> by following the instructions in etc/DEBUG about looping.

#26 0x00000000005187e4 in read_key_sequence (keybuf=0x7fff56c3d730,
     bufsize=30, prompt=11217297, dont_downcase_last=0,
     can_return_switch_frame=1, fix_current_buffer=1) at keyboard.c:9380
#27 0x0000000000508b20 in command_loop_1 () at keyboard.c:1696
#28 0x00000000005a42d5 in internal_condition_case (
     bfun=0x508798 <command_loop_1>, handlers=11331057,
     hfun=0x5080d2 <cmd_error>) at eval.c:1488
#29 0x00000000005084ba in command_loop_2 () at keyboard.c:1405
#30 0x00000000005a3c95 in internal_catch (tag=11305313,
---Type <return> to continue, or q <return> to quit---q
func=0x5084a0 <command_lQuit
) at eval.c:1223
#31 0x0000000000508474 in command_loop () at keyboard.c:1384
#32 0x0000000000507c19 in recursive_edit_1 () at keyboard.c:993
#33 0x0000000000507dbc in Frecursive_edit () at keyboard.c:1055
#34 0x0000000000506366 in main (argc=2, argv=0x7fff56c3e0e8) at emacs.c:1772

Lisp Backtrace:
"string-match" (0x12afbf3)
"flymake-parse-line" (0x158a523)
"flymake-parse-err-lines" (0xab2991)
"flymake-parse-output-and-residual" (0x158ad53)
"flymake-process-filter" (0x15ca604)
(gdb) f 5
#5  0x00000000005a7073 in Ffuncall (nargs=3, args=0x7fff56c3a060)
     at eval.c:3036
3036              val = (*XSUBR (fun)->function) (internal_args[0], 
internal_args[1],
(gdb) p args[1]
$1 = 19594227
(gdb) pr
" *\\(\\[javac\\]\\)? *\\(\\([a-zA-Z]:\\)?[^:(
]+\\):\\([0-9]+\\):[
]*\\(.+\\)"
(gdb)


If I remove the javac regexp from flymake.el everything is fine. I guess 
it does have problems matching all those whitespace (and it does not 
loop excessively as I first expected).

BTW, the gdb integration is very nice. Does anyone know about a similar 
.gdbinit for python?


Regards,
- Ralf

diff -r 09aac0f1e323 flymake.el
--- a/flymake.el        Wed Aug 08 11:50:47 2007 +0200
+++ b/flymake.el        Wed Aug 08 11:53:49 2007 +0200
@@ -918,8 +918,7 @@ Convert it to flymake internal format."
       ("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1)
       ;; LaTeX warnings (fileless) ("\\(LaTeX \\(Warning\\|Error\\): 
.*\\) on input line \\([0-9]+\\)" 20 3 nil 1)
       ;; ant/javac
-     (" *\\(\\[javac\\]\\)? 
*\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)"
-      2 4 nil 5))
+     )
     ;; compilation-error-regexp-alist)
     (flymake-reformat-err-line-patterns-from-compile-el 
compilation-error-regexp-alist-alist))
    "Patterns for matching error/warning lines.  Each pattern has the form

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: flymake mode freezes emacs
  2007-08-08 10:02       ` Ralf Schmitt
@ 2007-08-09  0:07         ` Richard Stallman
  2007-08-09  5:28           ` Ralf Schmitt
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2007-08-09  0:07 UTC (permalink / raw)
  To: Ralf Schmitt; +Cc: emacs-devel

    " *\\(\\[javac\\]\\)? *

That might be an infinite loop when there are spaces
but there is no [javac].  Please try replacing it with

    " *\\(\\[javac\\] *\\)?

If that doesn't fix the bug, then please follow the advice in
etc/DEBUG to find which of these frames the loop is in.

    Lisp Backtrace:
    "string-match" (0x12afbf3)
    "flymake-parse-line" (0x158a523)
    "flymake-parse-err-lines" (0xab2991)
    "flymake-parse-output-and-residual" (0x158ad53)
    "flymake-process-filter" (0x15ca604)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: flymake mode freezes emacs
  2007-08-09  0:07         ` Richard Stallman
@ 2007-08-09  5:28           ` Ralf Schmitt
  0 siblings, 0 replies; 7+ messages in thread
From: Ralf Schmitt @ 2007-08-09  5:28 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 244 bytes --]

Richard Stallman wrote:
>     " *\\(\\[javac\\]\\)? *
> 
> That might be an infinite loop when there are spaces
> but there is no [javac].  Please try replacing it with
> 
>     " *\\(\\[javac\\] *\\)?
> 

It does fix the bug.

Regards,
- Ralf

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 930 bytes --]

# HG changeset patch
# User ralf@brainbot.com
# Date 1186637047 -7200
# Node ID 33682a5d9e1ef9777ed53941178c8cd90b37be9f
# Parent  27407a272822df6df04dc8a5c1ae4249e8ddf807
fix

diff -r 27407a272822 -r 33682a5d9e1e flymake.el
--- a/flymake.el	Thu Aug 09 07:22:17 2007 +0200
+++ b/flymake.el	Thu Aug 09 07:24:07 2007 +0200
@@ -918,7 +918,7 @@ Convert it to flymake internal format."
      ("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1)
      ;; LaTeX warnings (fileless) ("\\(LaTeX \\(Warning\\|Error\\): .*\\) on input line \\([0-9]+\\)" 20 3 nil 1)
      ;; ant/javac
-     (" *\\(\\[javac\\]\\)? *\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)"
+     (" *\\(\\[javac\\] *\\)?\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)"
       2 4 nil 5))
    ;; compilation-error-regexp-alist)
    (flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist))

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-08-09  5:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-06  7:42 flymake mode freezes emacs Ralf Schmitt
2007-08-07  1:22 ` Richard Stallman
2007-08-07  7:05   ` Ralf Schmitt
2007-08-07 20:11     ` Richard Stallman
2007-08-08 10:02       ` Ralf Schmitt
2007-08-09  0:07         ` Richard Stallman
2007-08-09  5:28           ` Ralf Schmitt

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.