RFR: 8332287: When printing arguments in error logs, quote arguments with whitespaces [v2]

Thomas Stuefe stuefe at openjdk.org
Fri May 17 11:54:03 UTC 2024


On Thu, 16 May 2024 15:07:28 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> Trivial fix to a simple issue.
>> 
>> In hs-err files, when printing the arguments of the crashed JVM process, print arguments with whitespaces in them with quotes. Makes it easier to copy-paste them to terminals.
>> 
>> Before:
>> 
>> Command Line: -Dtest.vm.opts=-XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation -XX:+StressArrayCopyMacroNode -XX:+StressLCM -XX:+StressGCM -XX:+StressIGVN -XX:+StressCCP -XX:+StressMacroExpansion -XX:+StressMethodHandleLinkerInlining -XX:+StressCompiledExceptionHandlers -XX:CompileCommand=memlimit,*.*,1G~crash -XX:CompileCommand=memstat,*::*,print -Dtest.tool.vm.opts=-J-XX:+UnlockDiagnosticVMOptions -J-XX:-TieredCompilation -J-XX:+StressArrayCopyMacroNode -J-XX:+StressLCM -J-XX:+StressGCM -J-XX:+StressIGVN -J-XX:+StressCCP -J-XX:+StressMacroExpansion -J-XX:+StressMethodHandleLinkerInlining -J-XX:+StressCompiledExceptionHandlers -J-XX:CompileCommand=memlimit,*.*,1G~crash -J-XX:CompileCommand=memstat,*::*,print -XX:+StressCompiledExceptionHandlers -XX:CompileCommand=memlimit,*.*,1G~crash -XX:CompileCommand=memstat,*::*,print -Djava.library.path=/shared/projects/openjdk/jdk-jdk/output-fastdebug/images/test/hotspot/jtreg/native -Xbatch -XX:CompileCommand=option,*::*,bool,Vectorize
 ,true -XX:+PrintOpto -XX:+TraceLoopOpts com.sun.javatest.regtest.agent.MainWrapper /Users/thomas/shared/projects/openjdk/jtreg-runs/jtreg/JTwork/compiler/c2/TestFindNode.d/main.0.jta
>> 
>> 
>> Now (notice the gigantic -Dtest.vm.opts and -Dtest.tool.vm.opts that are actually just one large argument each)
>> 
>> 
>> Command Line: "-Dtest.vm.opts=-XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation -XX:+StressArrayCopyMacroNode -XX:+StressLCM -XX:+StressGCM -XX:+StressIGVN -XX:+StressCCP -XX:+StressMacroExpansion -XX:+StressMethodHandleLinkerInlining -XX:+StressCompiledExceptionHandlers -XX:CompileCommand=memlimit,*.*,1G~crash -XX:CompileCommand=memstat,*::*,print" "-Dtest.tool.vm.opts=-J-XX:+UnlockDiagnosticVMOptions -J-XX:-TieredCompilation -J-XX:+StressArrayCopyMacroNode -J-XX:+StressLCM -J-XX:+StressGCM -J-XX:+StressIGVN -J-XX:+StressCCP -J-XX:+StressMacroExpansion -J-XX:+StressMethodHandleLinkerInlining -J-XX:+StressCompiledExceptionHandlers -J-XX:CompileCommand=memlimit,*.*,1G~crash -J-XX:CompileCommand=memstat,*::*,print" -XX:+StressCompiledExceptionHandlers -XX:CompileCommand=memlimit,*.*,1G~crash -XX:CompileCommand=memstat,*::*,print -Djava.library.path=/shared/projects/openjdk/jdk-jdk/output-fastdebug/images/test/hotspot/jtreg/native -Xbatch -XX:Comp...
>
> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
> 
>   cast to unsigned

Hi Kevin,

> Are we saying we actually ran with, e.g. -Dtest.vm.opts="1 2 3" and we curently report in e.g. VM.info or hs_err as:
> 
> Command Line: -Dtest.vm.opts=1 2 3 AppName and: jvm_args: -Dtest.vm.opts=1 2 3

yes

> 
> But do we really want to report it with -Dtest.vm.opts itself inside the quotes - to make the copy/paste usable, we need to recognise -Dname=value args containing spaces, and add the first quote after the = sign?

No, its usable in its current form.

When copy-pasted into a terminal running bash, `A="1 2 3"` and `"A=1 2 3"` will expand to the same string `"A=1 2 3"`.

> 
> The scheme here would work for args to the app, e.g. java -Dtest.vm.opts="1 2 3" MyApp "one arg with spaces"
> 
> Currently reported as: Command Line: -Dtest.vm.opts=1 2 3 MyApp one arg with spaces
> 
> ..where the args to the Java app are misleading. However, if the arg to the Java app is:
> 
> java MyApp arg="arg with spaces"
> 
> ..then if we simply quote that one argument it may be clearer to humans, but may not be directly usable in a copy/paste.

I don't like the hs-err file to be too smart about this :) 

I would like to see the real argument vector, not some interpreted form of it. If something is given as a single argument containing spaces, that argument should be quoted. For that it does not matter if the arguments itself is later interpreted by the JVM or one of its daughter processes as a variable assignment.

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

PR Comment: https://git.openjdk.org/jdk/pull/19248#issuecomment-2117427930


More information about the hotspot-runtime-dev mailing list