This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 208487 - Live lock when formatting PHP file
Summary: Live lock when formatting PHP file
Status: RESOLVED DUPLICATE of bug 208652
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.2
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-16 09:38 UTC by schkovich
Modified: 2012-02-20 15:50 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Thread dump (39.82 KB, application/octet-stream)
2012-02-16 09:38 UTC, schkovich
Details
one more thread dump (37.96 KB, application/octet-stream)
2012-02-16 16:50 UTC, schkovich
Details
invoking code completion (31.26 KB, application/octet-stream)
2012-02-16 17:41 UTC, schkovich
Details
PHP thread dump (36.96 KB, application/octet-stream)
2012-02-17 16:13 UTC, schkovich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description schkovich 2012-02-16 09:38:44 UTC
Created attachment 115796 [details]
Thread dump

During testing of the new project scanning implementation I bumped into hard to reproduce problem: In some cases IDE will freeze after hitting alt+shift+f.

More details including profiler and application snap shots and heap dump could be found in the thread [71cat] Re: [news] Urgent call for help on NETCat mailing list.
Comment 1 Ondrej Brejla 2012-02-16 09:59:42 UTC
Your thread dump is quite strange, because lines are not corresponding with
lines in 7.2 build... I tried to reproduce it, but I'm not able to do that.
I'll monitor this strange behaviour... Thanks.
Comment 2 schkovich 2012-02-16 10:27:04 UTC
(In reply to comment #1)
> Your thread dump is quite strange, because lines are not corresponding with
> lines in 7.2 build... I tried to reproduce it, but I'm not able to do that.
> I'll monitor this strange behaviour... Thanks.
I used the tool you suggested. :) I can create new thread dump if you think I did something wrong. Just give me step by step instructions or ping me on gtalk.
Comment 3 Ondrej Brejla 2012-02-16 10:43:27 UTC
Yes please, create new dump. And if you have a file, where the problem is reproducible, please, attach it too. Thanks.
Comment 4 schkovich 2012-02-16 11:36:50 UTC
(In reply to comment #3)
> Yes please, create new dump. And if you have a file, where the problem is
> reproducible, please, attach it too. Thanks.
OK. I will try to create new thread dump. File in question has been changed meanwhile and I am not sure if the problem is reproducible. I can only send the file to you personally assuming that it will never go public.
Comment 5 Ondrej Brejla 2012-02-16 12:12:58 UTC
Yes, you can send it personally, I'll use it just for testing.
Comment 6 schkovich 2012-02-16 16:50:09 UTC
Created attachment 115835 [details]
one more thread dump

Product Version: NetBeans IDE Dev (Build 201202160400)
Java: 1.7.0; Java HotSpot(TM) 64-Bit Server VM 21.0-b17
System: Linux version 3.0.0-16-generic running on amd64; UTF-8; en_US (nb)

netbeans_default_options="--fontsize 14 --userdir ${HOME}/.netbeans/7.2-dev --laf javax.swing.plaf.metal.MetalLookAndFeel -J-client -J-Xss8m -J-Xms64m -J-XX:PermSize=256m -J-XX:MaxPermSize=512m -J-Xmx1024m -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled -J-XX:+UseParNewGC -J-Dnetbeans.logger.console=true -J-ea -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Djavax.net.ssl.trustStore=${HOME}/trackeystore -J-Djavax.net.ssl.trustStorePassword=xxxx -J-Dplugin.manager.check.updates=false  -J-Dsun.zip.disableMemoryMapping=true"

Running Ubuntu 11.10 on Apple iMac "Core i7" 3.4 27-Inch (Mid-2011)
Comment 7 schkovich 2012-02-16 17:41:21 UTC
Created attachment 115838 [details]
invoking code completion

It seams that problem is more widespread. I hit it when invoking code completion on defining methods.
Comment 8 schkovich 2012-02-16 17:53:27 UTC
It's about cache. I was not able to continue working and I started IDE with fresh user directory.

Code completion functions normally as well as formatting sent file.

Will the old user directory be of any use to you?

Feel free to close the ticket if you find that we cannot tackle the problem.
Comment 9 schkovich 2012-02-16 20:52:37 UTC
Actually this but is quite annoying. In last two hours I had to kill java and reopen IDE three times. Each time I was inserting some code from in one or other way: code completion, try/catch block, etc...

Using fresh user directory is just a temporary fix. :(
Comment 10 Ondrej Brejla 2012-02-17 07:55:29 UTC
When you hit CC, reformat is called, so it's still in formatter. But if I tried to format your confidental file, it worked properly, I have to investigate it more.
Comment 11 schkovich 2012-02-17 10:15:20 UTC
(In reply to comment #10)
> When you hit CC, reformat is called, so it's still in formatter. But if I tried
> to format your confidental file, it worked properly, I have to investigate it
> more.
I was sure that the file itself will not be helpful. I have a strong feeling that it is about cached data. 

I don't know how you guys are doing it exactly but I would most likely create tree like structure from the file, persist it and use it to manipulate nodes. 

Here is what I was doing last evening:
1. IDE freezes (same live lock in each case) after inserting desired "object" from selection list (code completion, wrapping selection in try/catch block or similar)
2. kill -9 pidofide
3. Open IDE try the same
4. Live lock encountered again
5. kill -9 pidofide
6. rm -r ~/.netbeans/user_dir
7. Open IDE try the same
8. No live lock
Comment 12 Ondrej Brejla 2012-02-17 11:44:40 UTC
Can you try to reproduce it with the piece of code from this issue #154019 ? 

In the first comment, there is a class Form inside <??>...select it with your mouse (including <??>) ctrl+c then open NB, with some opened PHP file, press ctrl+a (select all) press ctrl+v (to paste) and right after the pasting, press ctrl+shift+f

It freezes everytime for me...and thread dump is simillar as yours...(the last PHP "touch" is in TokenFormatter.replaceSimpleString())

But when you paste it, save it, close NB, open it again with the pasted code in a file, run Format...and magically, it works?
Comment 13 Ondrej Brejla 2012-02-17 13:57:59 UTC
CCing Mila, because he made some changes in BaseDocument.insertString()/remove() in parts, where problem "freezes" so maybe he could know more about it.
Comment 14 javydreamercsw 2012-02-17 14:00:27 UTC
This issue is not exclusive to PHP and seems to be more general. Sadly is hard
to reproduce. Maybe scanning/editing at the same time might corrupt part of
cache?
Comment 15 Ondrej Brejla 2012-02-17 14:10:32 UTC
Can you make a thread dump when it happens in another module than php? Thanks.
Comment 16 schkovich 2012-02-17 16:09:26 UTC
(In reply to comment #12)
> Can you try to reproduce it with the piece of code from this issue #154019 ? 
> 
> In the first comment, there is a class Form inside <??>...select it with your
> mouse (including <??>) ctrl+c then open NB, with some opened PHP file, press
> ctrl+a (select all) press ctrl+v (to paste) and right after the pasting, press
> ctrl+shift+f
> 
> It freezes everytime for me...and thread dump is simillar as yours...(the last
> PHP "touch" is in TokenFormatter.replaceSimpleString())
> 
> But when you paste it, save it, close NB, open it again with the pasted code in
> a file, run Format...and magically, it works?

Yup. That will be it. The only difference is that in my case saving and restarting IDE does not help: After hitting alt+shift+f IDE will freeze.
Comment 17 schkovich 2012-02-17 16:13:40 UTC
Created attachment 115885 [details]
PHP thread dump

Dump created while following Onderj's example
Comment 18 schkovich 2012-02-17 16:26:48 UTC
(In reply to comment #15)
> Can you make a thread dump when it happens in another module than php? Thanks.
I created HelloWorld Java project (tutorial). Copy/pasting and formatting worked correctly.

I am not working on Java projects. Perhaps Javier will be able to reproduce the problem and create thread dump.
Comment 19 Ondrej Brejla 2012-02-17 16:43:36 UTC
(In reply to comment #16)
> Yup. That will be it. The only difference is that in my case saving and
> restarting IDE does not help: After hitting alt+shift+f IDE will freeze.

It doesn't work for me either now. Don't know how I forced it to work properly :)
Comment 20 schkovich 2012-02-17 17:51:01 UTC
(In reply to comment #19)
> (In reply to comment #16)
> > Yup. That will be it. The only difference is that in my case saving and
> > restarting IDE does not help: After hitting alt+shift+f IDE will freeze.
> 
> It doesn't work for me either now. Don't know how I forced it to work properly
> :)
On the good side you have found a reliable way how to reproduce the problem.
Comment 21 javydreamercsw 2012-02-17 18:57:58 UTC
I will add it if it happens again. I was testing 7.1.1 the whole morning so I can get back to this. Can you point me on the process to generate the thread dump just in case?
Comment 22 schkovich 2012-02-17 19:07:03 UTC
(In reply to comment #21)
> I will add it if it happens again. I was testing 7.1.1 the whole morning so I
> can get back to this. Can you point me on the process to generate the thread
> dump just in case?
use visualvm: http://visualvm.java.net/
Comment 23 Ondrej Brejla 2012-02-20 09:00:19 UTC
Exactly as schkovich said, use Visual VM. It's a great tool for profiling.
Comment 24 Miloslav Metelka 2012-02-20 15:47:21 UTC
There was a problem in DirectMergeContainer that I've fixed.

*** This bug has been marked as a duplicate of bug 208652 ***
Comment 25 Ondrej Brejla 2012-02-20 15:50:27 UTC
Great, thanks!