On Sat, 6 Aug 2022 16:45:06 GMT, Julian Waters <jwat...@openjdk.org> wrote:

>> Please review a small patch for dumping the failure reason when the MSVCRT 
>> libraries or the Java Virtual Machine fails to load on Windows, which can 
>> provide invaluable insight when debugging related launcher issues. This also 
>> fixes a small bug in the Windows implementation of JLI_ErrorMessageSys where 
>> C runtime errors are never written to stderr.
>
> Julian Waters has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Back out change to DLL_ERROR4 for separate RFE

Nothing I could find in the tests that suggest they use this message as input, 
and none of them have failed with this patch, so I guess that's a good thing? :P

I am slightly concerned with going the route of 2 different calls for WIN32 and 
the C runtime, since `JLI_ReportErrorMessageSys` is a shared function, only the 
implementations differ from platform to platform. I can't think of any solution 
off the top of my head to implement such a change without drastically changing 
either the Unix variant as well, or the declaration's signature in the shared 
header unfortunately.

I was initially hesitant to change the formatting of spacing between the 
caller's message and system error, since the original intention for leaving it 
up to the caller may have been to allow for better flexibility. Also a concern 
was any behaviour differences that might result with the Unix variant, but it 
seems like the 2 format their messages entirely differently - While Windows 
appends the system error to the message without any formatting, Unix prints the 
system error on an entirely separate line above the message the caller passed 
it:

JNIEXPORT void JNICALL
JLI_ReportErrorMessageSys(const char* fmt, ...) {
    va_list vl;
    char *emsg;

    /*
     * TODO: its safer to use strerror_r but is not available on
     * Solaris 8. Until then....
     */
    emsg = strerror(errno);
    if (emsg != NULL) {
        fprintf(stderr, "%s\n", emsg);
    }

    va_start(vl, fmt);
    vfprintf(stderr, fmt, vl);
    fprintf(stderr, "\n");
    va_end(vl);
}


> If you can make the fix for the CRT extra info small, I'd go for it.

I don't quite get what you mean by that, should I revert the changes made to 
the freeit checks?

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

PR: https://git.openjdk.org/jdk/pull/9749

Reply via email to