You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "jlahoda (via GitHub)" <gi...@apache.org> on 2023/01/29 14:12:08 UTC

[GitHub] [netbeans] jlahoda opened a new pull request, #5384: [NETBEANS-4054] Ensuring progress when javac crashes while batch evaluating hints.

jlahoda opened a new pull request, #5384:
URL: https://github.com/apache/netbeans/pull/5384

   If hints are run on save, `BatchSearch` is called on a single file. Normally, if javac would crash during `toPhase`, an exception would be thrown. But, it may happen the existing parser is reused, and `toPhase` does not throw the exception, and this may be mistaken for an out-of-memory situation, to which the response is to restart the processing. This may then lead to an infinite loop.
   
   The proposed change here is to force progress in this situation. javac crash(es) need to be handled separately, of course.
   
   
   
   ---
   **^Add meaningful description above**
   
   By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
   
    - are all your own work, and you have the right to contribute them.
    - are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).
   
   Please make sure (eg. `git log`) that all commits have a valid name and email address for you in the Author field.
   
   If you're a first time contributor, see the Contributing guidelines for more information.
   
   If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a diff in pull request #5384: [NETBEANS-4054] Ensuring progress when javac crashes while batch evaluating hints.

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5384:
URL: https://github.com/apache/netbeans/pull/5384#discussion_r1090006555


##########
java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/batch/BatchSearch.java:
##########
@@ -246,8 +247,15 @@ public void run(CompilationController parameter) throws Exception {
                                 boolean cont = true;
 
                                 try {
-                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0)
+                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
+                                        if (currentInputList.size() == 1) {
+                                            //the javac crashed while processing the (single) file, we must ensure progress, otherwise infinite loop in processing would happen:
+                                            problems.add(new MessageImpl(MessageKind.WARNING, "An error occurred while processing file: " + FileUtil.getFileDisplayName(parameter.getFileObject()) + ", please see the IDE log for more information."));
+                                            currentPointer.incrementAndGet();
+                                        }
+
                                         return ;
+                                    }

Review Comment:
   this means that this can't happen when `BatchSearch` is used on multiple files because it wouldn't reuse javac instances there?
   
   So the only reason it tries again with the same file when `Phase.RESOLVED` can't be reached is because of a possible OOM situation?
   
   If that is the case we should add some kind of per-file retry counter. `while(true)` loops are always a bit of a danger zone.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a diff in pull request #5384: [NETBEANS-4054] Ensuring progress when javac crashes while batch evaluating hints.

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5384:
URL: https://github.com/apache/netbeans/pull/5384#discussion_r1090011330


##########
java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/batch/BatchSearch.java:
##########
@@ -246,8 +247,15 @@ public void run(CompilationController parameter) throws Exception {
                                 boolean cont = true;
 
                                 try {
-                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0)
+                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
+                                        if (currentInputList.size() == 1) {
+                                            //the javac crashed while processing the (single) file, we must ensure progress, otherwise infinite loop in processing would happen:
+                                            problems.add(new MessageImpl(MessageKind.WARNING, "An error occurred while processing file: " + FileUtil.getFileDisplayName(parameter.getFileObject()) + ", please see the IDE log for more information."));
+                                            currentPointer.incrementAndGet();
+                                        }
+
                                         return ;
+                                    }

Review Comment:
   sorry never mind this, I just noticed Jan posted a long explanation on the [issue](https://github.com/apache/netbeans/issues/4054#issuecomment-1407651558)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a diff in pull request #5384: [NETBEANS-4054] Ensuring progress when javac crashes while batch evaluating hints.

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5384:
URL: https://github.com/apache/netbeans/pull/5384#discussion_r1090011330


##########
java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/batch/BatchSearch.java:
##########
@@ -246,8 +247,15 @@ public void run(CompilationController parameter) throws Exception {
                                 boolean cont = true;
 
                                 try {
-                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0)
+                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
+                                        if (currentInputList.size() == 1) {
+                                            //the javac crashed while processing the (single) file, we must ensure progress, otherwise infinite loop in processing would happen:
+                                            problems.add(new MessageImpl(MessageKind.WARNING, "An error occurred while processing file: " + FileUtil.getFileDisplayName(parameter.getFileObject()) + ", please see the IDE log for more information."));
+                                            currentPointer.incrementAndGet();
+                                        }
+
                                         return ;
+                                    }

Review Comment:
   sorry never mind this, I just noticed @jlahoda  posted a long explanation as comment on the [issue](https://github.com/apache/netbeans/issues/4054#issuecomment-1407651558) which answers the questions. Although the retry counter might be still something we could consider to ensure there is no scenario where this loop can't exit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] neilcsmith-net merged pull request #5384: [NETBEANS-4054] Ensuring progress when javac crashes while batch evaluating hints.

Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net merged PR #5384:
URL: https://github.com/apache/netbeans/pull/5384


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a diff in pull request #5384: [NETBEANS-4054] Ensuring progress when javac crashes while batch evaluating hints.

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5384:
URL: https://github.com/apache/netbeans/pull/5384#discussion_r1090006555


##########
java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/batch/BatchSearch.java:
##########
@@ -246,8 +247,15 @@ public void run(CompilationController parameter) throws Exception {
                                 boolean cont = true;
 
                                 try {
-                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0)
+                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
+                                        if (currentInputList.size() == 1) {
+                                            //the javac crashed while processing the (single) file, we must ensure progress, otherwise infinite loop in processing would happen:
+                                            problems.add(new MessageImpl(MessageKind.WARNING, "An error occurred while processing file: " + FileUtil.getFileDisplayName(parameter.getFileObject()) + ", please see the IDE log for more information."));
+                                            currentPointer.incrementAndGet();
+                                        }
+
                                         return ;
+                                    }

Review Comment:
   ~~this means that this can't happen when `BatchSearch` is used on multiple files because it wouldn't reuse javac instances there?~~
   
   ~~So the only reason it tries again with the same file when `Phase.RESOLVED` can't be reached is because of a possible OOM situation?~~
   
   If that is the case we should add some kind of per-file retry counter. `while(true)` loops are always a bit of a danger zone.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a diff in pull request #5384: [NETBEANS-4054] Ensuring progress when javac crashes while batch evaluating hints.

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5384:
URL: https://github.com/apache/netbeans/pull/5384#discussion_r1090011330


##########
java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/batch/BatchSearch.java:
##########
@@ -246,8 +247,15 @@ public void run(CompilationController parameter) throws Exception {
                                 boolean cont = true;
 
                                 try {
-                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0)
+                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
+                                        if (currentInputList.size() == 1) {
+                                            //the javac crashed while processing the (single) file, we must ensure progress, otherwise infinite loop in processing would happen:
+                                            problems.add(new MessageImpl(MessageKind.WARNING, "An error occurred while processing file: " + FileUtil.getFileDisplayName(parameter.getFileObject()) + ", please see the IDE log for more information."));
+                                            currentPointer.incrementAndGet();
+                                        }
+
                                         return ;
+                                    }

Review Comment:
   sorry never mind this, I just noticed Jan posted a long explanation as comment on the [issue](https://github.com/apache/netbeans/issues/4054#issuecomment-1407651558) which answers the questions. Although the retry counter might be still something we could consider to ensure there is no scenario where this loop can't exit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a diff in pull request #5384: [NETBEANS-4054] Ensuring progress when javac crashes while batch evaluating hints.

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #5384:
URL: https://github.com/apache/netbeans/pull/5384#discussion_r1090011330


##########
java/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/batch/BatchSearch.java:
##########
@@ -246,8 +247,15 @@ public void run(CompilationController parameter) throws Exception {
                                 boolean cont = true;
 
                                 try {
-                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0)
+                                    if (parameter.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
+                                        if (currentInputList.size() == 1) {
+                                            //the javac crashed while processing the (single) file, we must ensure progress, otherwise infinite loop in processing would happen:
+                                            problems.add(new MessageImpl(MessageKind.WARNING, "An error occurred while processing file: " + FileUtil.getFileDisplayName(parameter.getFileObject()) + ", please see the IDE log for more information."));
+                                            currentPointer.incrementAndGet();
+                                        }
+
                                         return ;
+                                    }

Review Comment:
   sorry never mind this, I just noticed Jan posted a long explanation as comment on the [issue](https://github.com/apache/netbeans/issues/4054#issuecomment-1407651558)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists