Re: RFR: 8262157: LingeredApp.startAppExactJvmOpts does not print app output when launching fails

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8262157: LingeredApp.startAppExactJvmOpts does not print app output when launching fails

Chris Plummer-2
On Mon, 22 Feb 2021 22:26:50 GMT, Yumin Qi <[hidden email]> wrote:

> Hi, Please review
>
>  When debugging for other test case which uses jcmd to attach LingeredApp process, found there is no error information logged when the app started with function 'startAppExactJvmOpts' exits due to some reason. This is not convenient for trace what is the app failure.
>  This simple fix for adding finishApp to print out error information when LingeredApp could not start with startAppExactJvmOpts, this is similar to startApp.
>
> Tests: This is a simple fix and done tests with test/jdk/sun/tools/jinfo which uses the function startAppExactJvmOpts to create LingeredApp, also the test case in debugging, which indeed captured the error message upon start error.
>
> Thanks
> Yumin

test/lib/jdk/test/lib/apps/LingeredApp.java line 419:

> 417:             theApp.waitAppReady();
> 418:         } catch (Exception ex) {
> 419:             theApp.finishApp();

I'm worried about the output appearing twice in some tests:

        try {
            ...
            theApp = new LingeredAppWithLargeArray();
            LingeredApp.startAppExactJvmOpts(theApp, vmArgs);
            attachAndDump(heapDumpFileName, theApp.getPid());
        } finally {
            LingeredApp.stopApp(theApp);
            heapDumpFile.delete();
        }

So we always call `stopApp()`:

    public void stopApp() throws IOException {
           ...
           if (appProcess != null) {
           ...
            finishApp();
           ...
        }
    }


Which means we always call `finishApp()`, which means we always print the output. With your changes won't we see the output twice when there is an exception?

In the CR it looks like `LingeredApp.startAppExactJvmOpts()` is being call from `JCmdTest.java`. I don't see this test. Is it under development? Does it need a `stopApp()` call?

-------------

PR: https://git.openjdk.java.net/jdk/pull/2679
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8262157: LingeredApp.startAppExactJvmOpts does not print app output when launching fails

Ioi Lam-2
On Tue, 23 Feb 2021 02:55:01 GMT, Chris Plummer <[hidden email]> wrote:

>> Hi, Please review
>>
>>  When debugging for other test case which uses jcmd to attach LingeredApp process, found there is no error information logged when the app started with function 'startAppExactJvmOpts' exits due to some reason. This is not convenient for trace what is the app failure.
>>  This simple fix for adding finishApp to print out error information when LingeredApp could not start with startAppExactJvmOpts, this is similar to startApp.
>>
>> Tests: This is a simple fix and done tests with test/jdk/sun/tools/jinfo which uses the function startAppExactJvmOpts to create LingeredApp, also the test case in debugging, which indeed captured the error message upon start error.
>>
>> Thanks
>> Yumin
>
> test/lib/jdk/test/lib/apps/LingeredApp.java line 419:
>
>> 417:             theApp.waitAppReady();
>> 418:         } catch (Exception ex) {
>> 419:             theApp.finishApp();
>
> I'm worried about the output appearing twice in some tests:
>
>         try {
>             ...
>             theApp = new LingeredAppWithLargeArray();
>             LingeredApp.startAppExactJvmOpts(theApp, vmArgs);
>             attachAndDump(heapDumpFileName, theApp.getPid());
>         } finally {
>             LingeredApp.stopApp(theApp);
>             heapDumpFile.delete();
>         }
>
> So we always call `stopApp()`:
>
>     public void stopApp() throws IOException {
>            ...
>            if (appProcess != null) {
>            ...
>             finishApp();
>            ...
>         }
>     }
>
>
> Which means we always call `finishApp()`, which means we always print the output. With your changes won't we see the output twice when there is an exception?
>
> In the CR it looks like `LingeredApp.startAppExactJvmOpts()` is being call from `JCmdTest.java`. I don't see this test. Is it under development? Does it need a `stopApp()` call?

It seems error prone to have to call finishApp() manually in order to see the error log. Since LingeredApp.startApp calls finishApp() on exceptions, shouldn't startAppExactJvmOpts do the same thing?

-------------

PR: https://git.openjdk.java.net/jdk/pull/2679
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8262157: LingeredApp.startAppExactJvmOpts does not print app output when launching fails

Chris Plummer-2
On Tue, 23 Feb 2021 03:08:16 GMT, Ioi Lam <[hidden email]> wrote:

>> test/lib/jdk/test/lib/apps/LingeredApp.java line 419:
>>
>>> 417:             theApp.waitAppReady();
>>> 418:         } catch (Exception ex) {
>>> 419:             theApp.finishApp();
>>
>> I'm worried about the output appearing twice in some tests:
>>
>>         try {
>>             ...
>>             theApp = new LingeredAppWithLargeArray();
>>             LingeredApp.startAppExactJvmOpts(theApp, vmArgs);
>>             attachAndDump(heapDumpFileName, theApp.getPid());
>>         } finally {
>>             LingeredApp.stopApp(theApp);
>>             heapDumpFile.delete();
>>         }
>>
>> So we always call `stopApp()`:
>>
>>     public void stopApp() throws IOException {
>>            ...
>>            if (appProcess != null) {
>>            ...
>>             finishApp();
>>            ...
>>         }
>>     }
>>
>>
>> Which means we always call `finishApp()`, which means we always print the output. With your changes won't we see the output twice when there is an exception?
>>
>> In the CR it looks like `LingeredApp.startAppExactJvmOpts()` is being call from `JCmdTest.java`. I don't see this test. Is it under development? Does it need a `stopApp()` call?
>
> It seems error prone to have to call finishApp() manually in order to see the error log. Since LingeredApp.startApp calls finishApp() on exceptions, shouldn't startAppExactJvmOpts do the same thing?

Although you have a point, you've also pointed out another problem with this fix.  I think users of `startApp()` are already going to see the output twice because of the `finishApp()` call present there. By adding yet another `finishApp()` call to `startAppExactJvmOpts()`, now they will see it 3 times.

If you want to "move" the `finishApp()` call from `startApp()` to `startAppExactJvmOpts()`, then at least that will maintain the status quo with existing `startApp()` users, but we still have an issue with the output appearing twice, even before this change, and with this change it is now more common as `startAppExactJvmOpts()` will also start seeing it.

Maybe `finishApp()` should maintain an `alreadyCalled` flag so it does nothing on subsequent calls.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2679
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8262157: LingeredApp.startAppExactJvmOpts does not print app output when launching fails [v2]

Chris Plummer-2
On Tue, 23 Feb 2021 04:09:21 GMT, Yumin Qi <[hidden email]> wrote:

>> Although you have a point, you've also pointed out another problem with this fix.  I think users of `startApp()` are already going to see the output twice because of the `finishApp()` call present there. By adding yet another `finishApp()` call to `startAppExactJvmOpts()`, now they will see it 3 times.
>>
>> If you want to "move" the `finishApp()` call from `startApp()` to `startAppExactJvmOpts()`, then at least that will maintain the status quo with existing `startApp()` users, but we still have an issue with the output appearing twice, even before this change, and with this change it is now more common as `startAppExactJvmOpts()` will also start seeing it.
>>
>> Maybe `finishApp()` should maintain an `alreadyCalled` flag so it does nothing on subsequent calls.
>
> @plummercj @iklam Thanks for review. I will add a flag for finishApp so we will not call it more than once.

I still think the `finishApp()` call should be removed from `startApp()` since it is now in `startAppExactJvmOpts()`. Also move the `println()` to `startAppExactJvmOpts()` and then `startApp()` can just be:

             LingeredApp a = new LingeredApp();
             startApp(a, additionalJvmOpts);

No need for the exception handling anymore since `startAppExactJvmOpts()` is alread doing that.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2679