aBothe / Mono-D

D Add-In for MonoDevelop
http://wiki.dlang.org/Mono-D
Other
113 stars 26 forks source link

Infinite loop in parser #565

Closed etcimon closed 9 years ago

etcimon commented 9 years ago

Every couple of hours the parser gets stuck in an infinite loop, usually when I press space but before the space appears. It can happen in an if clause, in an array, anywhere. The monodevelop process goes unresponsive. Once I re-open, I can use space fine.

I've tried running gdb to attach to the process but I get an error

warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. ../../gdb/dwarf2-frame.c:692: internal-error: Unknown CFI encountered. A problem internal to GDB has been detected,

Any idea how to debug this?

aBothe commented 9 years ago

You can just run another instance of MonoDevelop inside MonoDevelop - that's how I normally develop Mono-D on Linux :) To accomplish this, I recommend you just to build Mono-D on your own, set up a symlink from the addin folder to you Mono-D-bin folder so the target MonoDevelop will always get the latest mono-d+d-parser.dll, and just debug Mono-D like I do :)

serates commented 9 years ago

+1 for this, for me I am having constant issues with monodevelop hanging for me. I can't use it for more than 15 minutes without reaching what sounds like this issue. I code for a while, and seemingly at random times monodevelop locks up entirely forcing me to force quit and relaunch. This prevents me from being able to use Mono-D consistently. I should also mention this has been around for a long time now. (I am running on linux, haven't really hit the hang as much on windows). If either of you have any suggestions to help (like if the hang goes away if i turn a setting off let me know).

aBothe commented 9 years ago

Since I probably won't be able to reproduce this issue, I'd strictly recommend to build & debug mono-d on your own, if your time allows it. I'll help you setting everything up (which isn't that complicated, apparently) then.

serates commented 9 years ago

I followed the instructions on the github, I'm running in debug now, if and when I hit the hang I'll post some information.

aBothe commented 9 years ago

As soon as it hangs, just hit the pause-button in the first monodevelop instance and make a screenshot of the callstack. :) Thanks for taking the time though!

serates commented 9 years ago

Okay i think i found the thread with the hang. For me, seems to be a completion related hang:

completionhang

Sorry for commandeering on this entry, the behavior i was hitting made it seem related to the above mentioned issue, is there a way to split this out to a separate thread?

aBothe commented 9 years ago

Looool, it's then the UI again - there once was a related issue with too long strings that couldn't be displayed quickly.

aBothe commented 9 years ago

Or..no, so it's hanging the entire time at this get_CompletionCategory method?

serates commented 9 years ago

Yeah, I just hit it again with the same trace, somehow the call into trygetvalue in Dictionary is hanging. Not sure exactly why it would.

serates commented 9 years ago

Maybe it's missing a readlock, is the Dictionary being accessed by other threads as well? A quick google mentions readlocks as potential hang point for calling TryGetValue()

aBothe commented 9 years ago

Please have a rebuild and try again. Perhaps it solved the readlock via magic circumstances. If not, there's gonna be a ConcurrentDictionay. But let's see first.

serates commented 9 years ago

So far so good, the change seems to have worked. Haven't hit a hang yet. If one pops up I'll let you know.

Thank you for your fast response!

aBothe commented 9 years ago

I've released v2.7.2. Hopefully this issue is going to be fixed now. :)

etcimon commented 9 years ago

Not for me!

https://github.com/etcimon/botan/blob/master/source/botan/pubkey/algo/dsa.d#L226

Pressing space after override freezes completely. Thankfuly it happens rarely enough that I just work around these particular situations. I didn't have the opportunity to look more into this, I don't have a second to spare in the office right now and I know I'll be spending the 5 minutes to 5 hours it takes to fix it if I start.

etcimon commented 9 years ago

Btw, if you notice the spacing issue it's because github doesn't cope well with tabs. I tried moving everything to spaces but mono-d defaults to tabs every time I open it up again. I think the right place for this would be with .editorconfig support

aBothe commented 9 years ago

Finally, a reproducible case. Thanks @etcimon :D

aBothe commented 9 years ago

@etcimon in your case, I suspect all these static ifs(BOTAN_SOME_MODE && ASDF) to cause these extreme lags. As an instant workaround, I've enabled timeouts for the operation lags I noticed. You may also reduce the completion timeout to 100 or 50ms in the D settings to reduce the laggy use and feel.

etcimon commented 9 years ago

Yes, my goal would most likely be to implement compile time parsing in mono-d eventually. It's advertised as an enhanced preprocessor so it will be commonly used that way, its a shame to see it break completion. Also, if you look at botan.tls.messages or extensions you might see a reproducible case for indentation bugs on large files, I don't remember which file but I also saw it on 500 line files where inserting a new line would put the text 5 tabs further. I'll find it later today :-p

aBothe commented 9 years ago

I'd really like to have it less accurate, just for the sake of performance, not correctness. Gonna see what I can do.

etcimon commented 9 years ago

I'd really like to have it less accurate, just for the sake of performance, not correctness. Gonna see what I can do.

I think a broader use of caches would help this, but I didn't really look into it that much ..

aBothe commented 9 years ago

It's using caches even now, I guess the filters are just broken or too unflexible

etcimon commented 9 years ago

The identation bug can be seen on this line (when pressing enter) https://github.com/etcimon/botan/blob/master/source/botan/pubkey/pubkey.d#L253

I encounter it less frenquently these days but it's been giving me a hard time...

aBothe commented 9 years ago

Alright, I've worked a little on the hashing visitor and the way it accesses the cache - and the response time went down to 1.5 seconds in the botan code. Caching ftw! I guess there could even be further things improved.

aBothe commented 9 years ago

It's likely that there are regressions noticable - but at least it's way faster now.

etcimon commented 9 years ago

I can't wait to try that! I'm getting a regression indeed, I can't really use the plugin right now because of this error in the linux x86_64 MonoDevelop 5.7 from your files in http://simendsjo.me/files/abothe/

Any ideas?

System.InvalidOperationException: Type 'MonoDevelop.D.Profiler.Gui.CodeCoverageEditorExtension' not found in add-in 'MonoDevelop.D,2.7.4'
  at Mono.Addins.RuntimeAddin.GetType (System.String typeName, Boolean throwIfNotFound) [0x00106] in /home/lx/Dokumente/Projects/monodevelop/main/external/mono-addins/Mono.Addins/Mono.Addins/RuntimeAddin.cs:342 
  at Mono.Addins.TypeExtensionNode.get_Type () [0x0002c] in /home/lx/Dokumente/Projects/monodevelop/main/external/mono-addins/Mono.Addins/Mono.Addins/TypeExtensionNode.cs:104 
  at MonoDevelop.Ide.Gui.Document.InitializeExtensionChain () [0x000c3] in /home/lx/Dokumente/Projects/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs:649 
  at MonoDevelop.Ide.Gui.Document.InitializeEditor (IExtensibleTextEditor editor) [0x0008e] in /home/lx/Dokumente/Projects/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs:705 
  at MonoDevelop.Ide.Gui.Document.OnDocumentAttached () [0x00011] in /home/lx/Dokumente/Projects/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs:712 
  at MonoDevelop.Ide.Gui.Workbench.WrapDocument (IWorkbenchWindow window) [0x0005b] in /home/lx/Dokumente/Projects/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs:732 
  at MonoDevelop.Ide.Gui.ViewCommandHandlers..ctor (IWorkbenchWindow window) [0x00015] in /home/lx/Dokumente/Projects/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs:49 
  at MonoDevelop.Ide.Gui.SdiWorkspaceWindow..ctor (MonoDevelop.Ide.Gui.DefaultWorkbench workbench, IViewContent content, MonoDevelop.Components.DockNotebook.DockNotebook tabControl, MonoDevelop.Components.DockNotebook.DockNotebookTab tabLabel) [0x0017d] in /home/lx/Dokumente/Projects/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs:125 
  at MonoDevelop.Ide.Gui.DefaultWorkbench.ShowView (IViewContent content, Boolean bringToFront, MonoDevelop.Components.DockNotebook.DockNotebook notebook) [0x00030] in /home/lx/Dokumente/Projects/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs:377 
  at MonoDevelop.Ide.Gui.LoadFileWrapper.Invoke (System.String fileName) [0x00204] in /home/lx/Dokumente/Projects/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs:1444 
  at MonoDevelop.Ide.Gui.Workbench.RealOpenFile (IProgressMonitor monitor, MonoDevelop.Ide.Gui.FileOpenInformation openFileInfo) [0x002f9] in /home/lx/Dokumente/Projects/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs:907 
aBothe commented 9 years ago

This error shouldn't be present - the manifest seems to be in order.

aBothe commented 9 years ago

Perhaps it's been solved now. By v2.7.5 I've released a regression hotfix. It's still not much faster than before, but caching might be more accurate now.

etcimon commented 9 years ago

You are amazing.

etcimon commented 9 years ago

Even the infiniloop is fixed

aBothe commented 9 years ago

Got to fix even further regressions though :)