Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Custom language.settings.xml file is not allways applied on project open

Hello to all,

 

Thanks @Alexander,

 

Seems ResourcesPlugin.getWorkspace().isTreeLocked()  caused eclipse freeze in my case.

 

@Jonah,

If I am doing just        storeInPrjArea.refreshLocal(IResource.DEPTH_ZERO, null);

And does not use svn plugin, it works well.

 

I still would like to know what could happen if I comment the file delete, as an extra step to be sure that the issue never occurs.

 

                        if (fileStorePrj.exists()) {

//                                  fileStorePrj.delete(true, null);

                        }

 

And seems that I would need to find a way to postpone the SVN job that is responsible to share projects, to avoid deadlock

 

Thank you

Kind Regards

Lidia

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Alexander Fedorov
Sent: Friday, December 13, 2019 8:25 AM
To: cdt-dev@xxxxxxxxxxx
Subject: Re: [cdt-dev] Custom language.settings.xml file is not allways applied on project open

 

Hi Lidia,

1) The condition ResourcesPlugin.getWorkspace().isTreeLocked() seems to be misused here, typically one should use it to either utilize IWorkspace.run or postpone the operation.
2) The timer-based decisions in the multi-thread environment will have unpredictable results by definition.
3) Please have a look on more recent implementation in master, it uses more appropriate "locks" approach, hope it will help you
https://github.com/eclipse-cdt/cdt/blob/master/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java

Regards,
AF

13.12.2019 0:13, Popescu, Lidia пишет:

Hi Jonah,

 

If I am not using SVN plugins, when it goes wrong, and is supposed to refresh the file,

for some reason eclipse freezes, the spinner is loading forever on project open, when it is supposed to delay at most 20 seconds, based on my code:

 

In  org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer

I can see the first log, but not the second log, any of them, it usually goes to else clause.

 

public static void loadLanguageSettings(ICProjectDescription prjDescription) {

                             IProject project = prjDescription.getProject();

                             IFile storeInPrjArea = getStoreInProjectArea(project);

                             boolean isStoreInProjectAreaExist = storeInPrjArea.exists();

                            

                             // My Fix

                             if ( !isStoreInProjectAreaExist) {

                                          

                                           CCorePlugin.getDefault().getLog().log(new Status(IStatus.INFO , CCorePlugin.PLUGIN_ID, prjDescription.getProject() +": isStoreInProjectAreaExist= "+ isStoreInProjectAreaExist)); //$NON-NLS-1$ 

                                           try {

                                                          if ( ResourcesPlugin.getWorkspace().isTreeLocked() ) {

                                                                        long current = System.currentTimeMillis();

                                                                       

                                                                        while ( !isStoreInProjectAreaExist ) {

                                                                                      Thread.sleep(3000);

                                                                                      project = prjDescription.getProject();

                                                                                      storeInPrjArea = getStoreInProjectArea(project);

                                                                                      isStoreInProjectAreaExist = storeInPrjArea.exists();

                                                                                      if ( !isStoreInProjectAreaExist && System.currentTimeMillis() - current > 20000) {

                                                                                                     break;

                                                                                      }

                                                                        }

                                                                        CCorePlugin.log(new Status(IStatus.INFO , CCorePlugin.PLUGIN_ID, prjDescription.getProject() +": isStoreInProjectAreaExist#1.1= "+ isStoreInProjectAreaExist + " in " +(System.currentTimeMillis() - current )) ); //$NON-NLS-1$ //$NON-NLS-2$

                                                         

                                                          }

                                                          else {

                                                                        // could throw resource tree is locked for modifications

                                                                        storeInPrjArea.refreshLocal(IResource.DEPTH_ZERO, null);

                                                                        isStoreInProjectAreaExist = storeInPrjArea.exists();

                                                                        CCorePlugin.getDefault().getLog().log(new Status(IStatus.INFO , CCorePlugin.PLUGIN_ID, prjDescription.getProject() +": isStoreInProjectAreaExist#1.2= "+ isStoreInProjectAreaExist)); //$NON-NLS-1$

                                                          }

                                                         

 

Thank you

Kind Regards

Lidia

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Jonah Graham
Sent: Thursday, December 12, 2019 10:34 PM
To: CDT General developers list.
Subject: Re: [cdt-dev] Custom language.settings.xml file is not allways applied on project open

 

Hi Lidia,

 

So, if you don't have SVN involved (installed in your eclipse) it all works fine? Or is SVN only a problem with refresh workaround?

 

Thanks

Jonah


~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com

 

 

On Thu, 12 Dec 2019 at 15:15, Popescu, Lidia <lidia.popescu@xxxxxxxxxxxxx> wrote:

Hello Jonah, all,

 

Regarding this topic,

 

Unfortunately using

+        storeInPrjArea.refreshLocal(IResource.DEPTH_ZERO, null);
is not helping.

 

It seems to help , from UI seems to be ok, but in the Logs I can see following DeadLocks for about every second project that I open.

The projects we create are based on existing sources that has svn. On open, SVN plugin shares them automatically and this causes following deadlock.

I suppose both, cdt and svn plugins are trying to refresh/access same resources at the same time.

 

!MESSAGE Deadlock detected. All locks owned by thread main will be suspended.

java.lang.IllegalStateException

              at org.eclipse.core.internal.jobs.DeadlockDetector.reportDeadlock(DeadlockDetector.java:599)

              at org.eclipse.core.internal.jobs.DeadlockDetector.lockWaitStart(DeadlockDetector.java:403)

              at org.eclipse.core.internal.jobs.LockManager.addLockWaitThread(LockManager.java:154)

              at org.eclipse.core.internal.jobs.OrderedLock.doAcquire(OrderedLock.java:168)

              at org.eclipse.core.internal.jobs.OrderedLock.acquire(OrderedLock.java:106)

              at org.eclipse.core.internal.jobs.OrderedLock.acquire(OrderedLock.java:82)

              at org.eclipse.cdt.internal.core.settings.model.xml.XmlProjectDescriptionStorage.getProjectDescription(XmlProjectDescriptionStorage.java:230)

              at org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.getProjectDescriptionInternal(CProjectDescriptionManager.java:426)

              at org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.getProjectDescription(CProjectDescriptionManager.java:408)

              at org.eclipse.cdt.managedbuilder.core.ManagedBuildManager.findBuildInfo(ManagedBuildManager.java:2730)

              at org.eclipse.cdt.managedbuilder.core.ManagedBuildManager.getBuildInfo(ManagedBuildManager.java:2991)

              at org.eclipse.cdt.managedbuilder.core.ManagedBuildManager.getBuildInfo(ManagedBuildManager.java:2946)

              at org.eclipse.cdt.managedbuilder.core.ResourceChangeHandler2$Visitor.visit(ResourceChangeHandler2.java:123)

              at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:64)

              at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:75)

              at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:48)

              at org.eclipse.cdt.managedbuilder.core.ResourceChangeHandler2.resourceChanged(ResourceChangeHandler2.java:180)

              at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:299)

              at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)

              at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:289)

              at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:152)

              at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:374)

              at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1469)

              at org.eclipse.core.internal.resources.Project.touch(Project.java:1326)

              at org.eclipse.team.core.RepositoryProvider.map(RepositoryProvider.java:132)

              at org.tigris.subversion.subclipse.core.resources.SVNWorkspaceRoot.setSharing(SVNWorkspaceRoot.java:229)

              at org.tigris.subversion.subclipse.core.SVNTeamProviderType$AutoShareJob.autoconnectSVNProject(SVNTeamProviderType.java:136)

              at org.tigris.subversion.subclipse.core.SVNTeamProviderType$AutoShareJob.run(SVNTeamProviderType.java:98)

              at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)

!SUBENTRY 1 org.eclipse.core.jobs 4 2 2019-12-12 16:37:41.647

!MESSAGE Thread Worker-3 has locks: F/DemoProject/.settings, R/, OrderedLock (7), OrderedLock (0) and is waiting for lock OrderedLock (11)

!SUBENTRY 1 org.eclipse.core.jobs 4 2 2019-12-12 16:37:41.647

!MESSAGE Thread main has locks: OrderedLock (11) and is waiting for lock F/DemoProject/.settings

 

Not sure if I can ignore such errors.

 

I also found that, at some point the language settings that I want to apply is removed, when it goes wrong.

And if I comment following line in yellow, it seems to solve my problem.

Even if in the beginning isStoreInProjectAreaExist = false,but if the language settings file is not removed, at some point it is successfully applied.

 

What side effect it could cause if I comment this line ?

Or maybe you have other ideas? How could I postpone this workflow ? that checks and loadLanguageSettings()

 

In  org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer.serializeLanguageSettings(ICProjectDescription prjDescription)

 

try {

            serializingLock.acquire();

 

            if (!isEqualToDefaultProviders(prjDescription)) {

                        serializeLanguageSettingsInternal(projectElementStorePrj, projectElementStoreWsp, prjDescription);

            }

 

            // Absent store means default providers as specified in the toolchain

            IFile fileStorePrj = getStoreInProjectArea(project);

            boolean isProjectStoreEmpty = projectElementStorePrj.getChildNodes().getLength() == 0;

            if (isProjectStoreEmpty) {

                        if (fileStorePrj.exists()) {

//                                  fileStorePrj.delete(true, null);

                        }

            } else {

 

 

Thank you in advance

Kind Regards

Lidia

 

From: Popescu, Lidia
Sent: Tuesday, December 10, 2019 10:46 PM
To: CDT General developers list.
Subject: RE: [cdt-dev] Custom language.settings.xml file is not allways applied on project open

 

Thanks Jonah,

 

Your snipped seems to help, same as mine where I just added Thread.sleep() for 5 seconds and re-tried to get the file and boolean value.

But I still have to see if it fixes the problem on someone’s else side, who happens to have it more often.

 

I will let you know then how it goes.

 

Kind Regards

Lidia

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Jonah Graham
Sent: Tuesday, December 10, 2019 10:08 PM
To: CDT General developers list.
Subject: Re: [cdt-dev] Custom language.settings.xml file is not allways applied on project open

 

Hello Lidia,

 

Unfortunately there are indeed some race conditions in the code - It looks like you have discovered one of them. 

 

If it is a refresh problem, I wonder if doing the below would help. Can you try it?

 

        public static void loadLanguageSettings(ICProjectDescription prjDescription) {
                IProject project = prjDescription.getProject();
                IFile storeInPrjArea = getStoreInProjectArea(project);
+               try {
+                       storeInPrjArea.refreshLocal(IResource.DEPTH_ZERO, null);
+               } catch (CoreException e1) {
+               }
                boolean isStoreInProjectAreaExist = storeInPrjArea.exists();
                if (isStoreInProjectAreaExist) {
                        Document doc = null;

 

Perhaps that will make sure the state of the file is up to date. I am not sure what (negative) side effects there are with doing that here - as a first step it would be good to know if that resolves the issue.

 

Jonah


~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com

 

 

On Tue, 10 Dec 2019 at 14:37, Popescu, Lidia <lidia.popescu@xxxxxxxxxxxxx> wrote:

Hello cdt developers,

 

I am investigating an issue that randomly occurs on our side on eclipse for linux, with CDT 9.4.3.

I am trying to reproduce it on windows, latest cdt, but I have a bit different behavior. Could it be a cdt bug ?  a race condition maybe.

 

We are generating programmatically some cdt projects based on existing templates, including the .settings/language.settings.xml files, and leave the project closed after creation.

 

Then, when a project is open, our custom language settings are not always applied, and sometimes even removed.

 

I investigated the problem and I found that

it happens because it sometimes checks too early if .settings/language.settings.xml file exists, maybe before some refresh jobs finishes, and the file is not accessible as a resource, so isStoreInProjectAreaExist=false, and it loads defaults configuration for language settings.

 

The loadLanguageSettings() is called

And it checks

 

loadLanguageSettings () {

IFile storeInPrjArea = getStoreInProjectArea(project);

boolean isStoreInProjectAreaExist = storeInPrjArea.exists();

 

// and based on result it loads default language settigns or custom from existing .settings/language.settings file

if (isStoreInProjectAreaExist) {

                        System.out.println("    >>> Load from xml file"); . . .

} else {

                        System.out.println("   >>> Load default"); . . .

}

}

 

That is a sample of jobs/processes that are running:

 

A bad sample, when our language settings is not applied:

 

 

A good sample when our custom language settings is applied:

 

 

It goes well when the job ‘Discover compiler build-in language settings’ is executed and in Project properties -> C/C++ General -> Preprocessor Include Paths, macros   Page we can see configuration from our custom language.setttings.xml

 

 

I am not sure yet what process it depends on, but if I wait a bit and re-request value for boolean isStoreInProjectAreaExist = storeInPrjArea.exists();, it returns desired true value.

Could you please help me with this?

 

I will try to reproduce it in eclipse oxygen, with cdt 9.4.3 on windows.

 

 

Thank you

Kind Regards

Lidia

 

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev



_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev

 


Back to the top