senny / emacs-eclim

This project brings some of the great eclipse features to emacs developers. It is based on the eclim project, which provides eclipse features for vim.
http://www.emacswiki.org/emacs/EmacsEclim
587 stars 102 forks source link

The delete-file advice blocks in files with special characters in file name #241

Closed relex closed 9 years ago

relex commented 9 years ago

Reproduction

  1. Load emacs-eclim
  2. Create a file named "#asdf#"
  3. M-x delete-file #asdf#
  4. Emacs gets stuck

    Further investigation

I noticed a problem related to the advice made for delete-file.

I have some kind of auto-save functionality enabled that occasionally deletes temporary files using delete-file. When this happens my Emacs gets stuck in the eclim-project-name-function. Here's one example stacktrace after quitting the stuck process with C-g:

Debugger entered--Lisp error: (quit)
  call-process("/bin/bash" nil t nil "-c" "/Users/martin/Applications/Eclipse.app/Contents/Eclipse/eclim -command project_by_resource -f /Users/martin/.emacs.d/.cache/auto-save/site/\\#\\!Users\\!martin\\!git\\!processor-fastorm\\!.git\\!COMMIT_EDITMSG\\#")
  apply(call-process "/bin/bash" nil t nil ("-c" "/Users/martin/Applications/Eclipse.app/Contents/Eclipse/eclim -command project_by_resource -f /Users/martin/.emacs.d/.cache/auto-save/site/\\#\\!Users\\!martin\\!git\\!processor-fastorm\\!.git\\!COMMIT_EDITMSG\\#"))
  process-file("/bin/bash" nil t nil "-c" "/Users/martin/Applications/Eclipse.app/Contents/Eclipse/eclim -command project_by_resource -f /Users/martin/.emacs.d/.cache/auto-save/site/\\#\\!Users\\!martin\\!git\\!processor-fastorm\\!.git\\!COMMIT_EDITMSG\\#")
  shell-command-to-string("/Users/martin/Applications/Eclipse.app/Contents/Eclipse/eclim -command project_by_resource -f /Users/martin/.emacs.d/.cache/auto-save/site/\\#\\!Users\\!martin\\!git\\!processor-fastorm\\!.git\\!COMMIT_EDITMSG\\#")
  eclim--call-process("project_by_resource" "-f" "/Users/martin/.emacs.d/.cache/auto-save/site/#!Users!martin!git!processor-fastorm!.git!COMMIT_EDITMSG#")
  apply(eclim--call-process ("project_by_resource" "-f" "/Users/martin/.emacs.d/.cache/auto-save/site/#!Users!martin!git!processor-fastorm!.git!COMMIT_EDITMSG#"))
  #[(command-line on-complete-fn) "\303\304\"\n \210  )\207" [command-line res on-complete-fn apply eclim--call-process] 3](("project_by_resource" "-f" "/Users/martin/.emacs.d/.cache/auto-save/site/#!Users!martin!git!processor-fastorm!.git!COMMIT_EDITMSG#") (lambda (&rest --cl-rest--) (apply (quote #[(G25363 G25364 G25365) "J\205F\303\304 !\305\304 !\205E\n\205E\n\3068\262\211A@\262 \3068\262\211A@\262U\203@\n\3078\262  \3078\262U?\205E\310\311\211\211#)\207" [G25364 attrs-curr attrs-before file-attributes buffer-file-name file-exists-p 5 7 revert-buffer t] 4]) (quote --check--) (quote --sync--) (quote --expargs--) --cl-rest--)))
  eclim--execute-command-internal(#[(command-line on-complete-fn) "\303\304\"\n \210  )\207" [command-line res on-complete-fn apply eclim--call-process] 3] "project_by_resource" (("-f" file)))
  #[(file) "\300\301\302\303#\207" [eclim--execute-command-internal #[(command-line on-complete-fn) "\303\304\"\n \210    )\207" [command-line res on-complete-fn apply eclim--call-process] 3] "project_by_resource" (("-f" file))] 4]("/Users/martin/.emacs.d/.cache/auto-save/site/#!Users!martin!git!processor-fastorm!.git!COMMIT_EDITMSG#")
  eclim-project-name("/Users/martin/.emacs.d/.cache/auto-save/site/#!Users!martin!git!processor-fastorm!.git!COMMIT_EDITMSG#")
  byte-code("\303!\211\203\304\305 !\"\303\207" [filename pr fn eclim-project-name file-relative-name eclim--project-dir] 4)
  ad-Advice-delete-file(#<subr delete-file> "/Users/martin/.emacs.d/.cache/auto-save/site/#!Users!martin!git!processor-fastorm!.git!COMMIT_EDITMSG#")
  apply(ad-Advice-delete-file #<subr delete-file> "/Users/martin/.emacs.d/.cache/auto-save/site/#!Users!martin!git!processor-fastorm!.git!COMMIT_EDITMSG#")
  delete-file("/Users/martin/.emacs.d/.cache/auto-save/site/#!Users!martin!git!project!.git!COMMIT_EDITMSG#")
  #[0 "\301!\207" [buffer-auto-save-file-name delete-file] 2 "\n\n(fn)"]()
  funcall(#[0 "\301!\207" [buffer-auto-save-file-name delete-file] 2 "\n\n(fn)"])
  delete-auto-save-file-if-necessary(t)
  basic-save-buffer()
  save-buffer()
  with-editor-return(nil)
  with-editor-finish(nil)
  call-interactively(with-editor-finish nil nil)
  command-execute(with-editor-finish)

Looking at the error in eclimd output shows the following:

NGSession 1: 127.0.0.1: org.eclim.command.Main exited with status 1
2015-09-02 17:14:58,650 ERROR [org.eclim.command.Main] Command failed
java.net.URISyntaxException: Illegal character in fragment at index 108: file:///Users/martin/.emacs.d/.cache/auto-save/site/#!Users!martin!git!project!.git!COMMIT_EDITMSG#
    at java.net.URI$Parser.fail(URI.java:2829)
    at java.net.URI$Parser.checkChars(URI.java:3002)
    at java.net.URI$Parser.parse(URI.java:3048)
    at java.net.URI.<init>(URI.java:595)
    at org.eclim.plugin.core.command.project.ProjectByResource.execute(ProjectByResource.java:55)
    at org.eclim.command.Main$1.run(Main.java:100)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4024)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3700)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
    at org.eclim.eclipse.EclimApplication.start(EclimApplication.java:128)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1488)

Strangely the command only blocks when called through Emacs e.g. with M-x shell-command. Running the command from a terminal returns the error stacktrace.

Marbook-Pro:~ martin$ /Users/martin/Applications/Eclipse.app/Contents/Eclipse/eclim -command project_by_resource -f /Users/martin/#asdf#
java.net.URISyntaxException: Illegal character in fragment at index 26: file:///Users/martin/#asdf#
    at java.net.URI$Parser.fail(URI.java:2829)
    at java.net.URI$Parser.checkChars(URI.java:3002)
etc...

Discussion about solutions

  1. Can special characters be escaped when passing them to Eclim?
  2. Is this a bug in Eclim? Should Eclim handle special characters in filenames?
  3. Why does the eclim-executable block when eclimd throws an error in Emacs but not in a terminal?
relex commented 9 years ago

I figured it out. The problem was related to using Prodigy to manage the eclimd process. If I start eclimd outside of Emacs it doesn't block anymore.

myrjola commented 9 years ago

For the record it was me that reported this issue, but I used a shared account by mistake.