RFR: 8353439: Shell grouping of -XX:OnError= commands is surprising
Kevin Walls
kevinw at openjdk.org
Fri Apr 4 07:58:50 UTC 2025
On Fri, 4 Apr 2025 01:17:50 GMT, David Holmes <dholmes at openjdk.org> wrote:
> I am having trouble understanding how the current behaviour can actually work. If I have
Well, it works 8-) I can't get sh -c "command\ncommand" to work at the command-line, but strace shows it works when the JVM execs it.
e.g.
java -XX:CICrashAt=2 -XX:OnError="echo ONE" -XX:OnError="echo TWO" ...program...
...
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#
#
# -XX:OnError="echo ONE
echo TWO"
# Executing /bin/sh -c "echo ONE
echo TWO" ...
ONE
TWO
Aborted (core dumped)
When it logs for the above message, it writes the command ccstrlist it has:
1508906 write(1, "echo ONE\necho TWO", 17) = 17
and only execs one shell:
1508911 execve("/bin/sh", ["sh", "-c", "echo ONE\necho TWO"], 0x7ffeb584b798 /* 70 vars */ <unfinished ...>
..and nothing else. If I make it run /bin/echo not builtin:
-XX:OnError="/bin/echo ONE" -XX:OnError="/bin/echo TWO"
I see one shell and two /bin/echo programs run:
$ grep exec strace.out
1508926 execve("build/linux-x64/images/jdk/bin/java", ["build/linux-x64/images/jdk/bin/j"..., "-XX:CICrashAt=2", "-XX:OnError=/bin/echo ONE", "-XX:OnError=/bin/echo TWO", "-cp", "/progs", "MyProg"], 0x7ffddf65ff48 /* 70 vars */) = 0
...
1508950 execve("/bin/sh", ["sh", "-c", "/bin/echo ONE\n/bin/echo TWO"], 0x7ffe2927e608 /* 70 vars */ <unfinished ...>
1508951 execve("/bin/echo", ["/bin/echo", "ONE"], 0x55f33ff96b60 /* 70 vars */) = 0
1508950 execve("/bin/echo", ["/bin/echo", "TWO"], 0x55f33ff978c0 /* 70 vars */) = 0
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24354#issuecomment-2777859714
More information about the hotspot-dev
mailing list